Skip to content

Commit cac2d0e

Browse files
akinomyogascop
andcommitted
refactor(_comp_dequote): apply suggestions from code review
Co-authored-by: Ville Skyttä <[email protected]>
1 parent b962eb8 commit cac2d0e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

bash_completion

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,14 @@ quote_readline()
176176
_comp_dequote__initialize()
177177
{
178178
unset -f "$FUNCNAME"
179-
local param='\$([_a-zA-Z][_a-zA-Z0-9]*|[-*@#?$!0-9_])|\$\{[!#]?([_a-zA-Z][_a-zA-Z0-9]*(\[([0-9]+|[*@])\])?|[-*@#?$!0-9_])\}'
180-
local quote='\\.|'\''[^'\'']*'\''|\$?"([^\"$`!]|'$param'|\\.)*"|\$'\''([^\'\'']|\\.)*'\'''
181-
_comp_dequote__regex_safe_word='^([^\'\''"$`;&|<>()!]|'$quote'|'$param')*$'
179+
local regex_param='\$([_a-zA-Z][_a-zA-Z0-9]*|[-*@#?$!0-9_])|\$\{[!#]?([_a-zA-Z][_a-zA-Z0-9]*(\[([0-9]+|[*@])\])?|[-*@#?$!0-9_])\}'
180+
local regex_quoted='\\.|'\''[^'\'']*'\''|\$?"([^\"$`!]|'$regex_param'|\\.)*"|\$'\''([^\'\'']|\\.)*'\'''
181+
_comp_dequote__regex_safe_word='^([^\'\''"$`;&|<>()!]|'$regex_quoted'|'$regex_param')*$'
182182
}
183183
_comp_dequote__initialize
184184

185185
# This function expands a word using `eval` in a safe way. This function can
186-
# be typically used to get the expqanded value of `${word[i]}` as
186+
# be typically used to get the expanded value of `${word[i]}` as
187187
# `_comp_dequote "${word[i]}"`. When the word contains unquoted shell special
188188
# characters, command substitutions, and other unsafe strings, the function
189189
# call fails before applying `eval`. Otherwise, `eval` is applied to the
@@ -240,9 +240,9 @@ dequote()
240240
{
241241
local ret
242242
_comp_dequote "$1"
243-
local ext=$?
243+
local rc=$?
244244
printf %s "$ret"
245-
return $ext
245+
return $rc
246246
}
247247

248248
# Unset the given variables across a scope boundary. Useful for unshadowing

0 commit comments

Comments
 (0)