Fix __reassemble_comp_words_by_ref() unquoted pattern removal
Commit 8227e76
was failing on these `chown' tests in bash-4.1:
FAIL: Check preserve special chars in funky\ user:Debia<TAB>
FAIL: Check preserve special chars in funky\.user:Debia<TAB>
FAIL: Check preserve special chars in fu\ nky.user:Debia<TAB>
FAIL: Check preserve special chars in f\ o\ o\.\bar:Debia<TAB>
FAIL: Check preserve special chars in foo\_b\ a\.r\ :Debia<TAB>
because a removal pattern is expanded:
$ a=\\b
$ w=\\
$ echo ${a#$w} # Doesn't work
\b
$ echo ${a#"$w"} # Ok
b
master
parent
8c3a0e94d1
commit
7cd17ada11
|
@ -310,8 +310,8 @@ __reassemble_comp_words_by_ref() {
|
|||
eval $2[$j]=\${!ref}\${COMP_WORDS[i]}
|
||||
# Indicate new cword
|
||||
[ $i = $COMP_CWORD ] && eval $3=$j
|
||||
# Remove whitespace (optional) + word separator from line copy
|
||||
line=${line#*${COMP_WORDS[$i]}}
|
||||
# Remove optional whitespace + word separator from line copy
|
||||
line=${line#*"${COMP_WORDS[$i]}"}
|
||||
# Start new word if word separator in original line is
|
||||
# followed by whitespace.
|
||||
[[ ${line:0:1} == ' ' || ${line:0:1} == $'\t' ]] && ((j++))
|
||||
|
@ -322,8 +322,8 @@ __reassemble_comp_words_by_ref() {
|
|||
# Append word to current word
|
||||
ref="$2[$j]"
|
||||
eval $2[$j]=\${!ref}\${COMP_WORDS[i]}
|
||||
# Remove whitespace (optional) + word from line copy
|
||||
line=${line#*${COMP_WORDS[i]}}
|
||||
# Remove optional whitespace + word from line copy
|
||||
line=${line#*"${COMP_WORDS[i]}"}
|
||||
# Indicate new cword
|
||||
[[ $i == $COMP_CWORD ]] && eval $3=$j
|
||||
done
|
||||
|
|
|
@ -438,4 +438,19 @@ assert_bash_list {"a b :c"} $cmd $test
|
|||
sync_after_int
|
||||
|
||||
|
||||
set test {a b\ :c| with WORDBREAKS -= :}; # | = cursor position
|
||||
if {[lindex $::BASH_VERSINFO 0] <= 3} {
|
||||
set cmd {COMP_WORDS=(a "b\\ :c"); COMP_CWORD=1}
|
||||
} else {
|
||||
set cmd {COMP_WORDS=(a "b\\ " : c); COMP_CWORD=3}
|
||||
}
|
||||
append cmd {; COMP_LINE='a b\ :c'; COMP_POINT=7}
|
||||
assert_bash_exec $cmd $test
|
||||
set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
|
||||
assert_bash_list {a "b\\ :c"} $cmd $test
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
||||
|
|
Loading…
Reference in New Issue