-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Bash tab completion doesn't handle backslashes correctly #100
Comments
I can't reproduce this, but I think it is possible this is fixed as a result of #91 (comment) |
I can't reproduce my example anymore either, so it looks something about this problem has changed, but now I've found a new issue: Tab completion seems to be processing escape sequences and splitting words as a result #!/usr/bin/env bash
generate_suggestions() {
local suggestions=(
'foo\>bar1'
'foo\>bar2'
)
local i
for ((i=0; i < ${#suggestions[@]}; i++)); do
# compgen -W respects shell quoting, so we need to escape special
# characters.
suggestions[i]="$(printf "%q" "${suggestions[i]}")"
done
local cur="${COMP_WORDS[COMP_CWORD]}"
# compgen -W respects shell quoting _after_ checking to make sure elements of
# the wordlist start with ${cur}, so we need to escape it, too.
cur="$(printf "%q" "${cur}")"
mapfile -t COMPREPLY < <(compgen -W "${suggestions[*]}" -- "${cur}")
local log="completion.log"
{
echo "COMP_WORDS"
local i
for ((i=0; i < "${#COMP_WORDS[@]}"; i++)); do
local cur=" "
if ((i == COMP_CWORD)); then
cur="*"
fi
echo "${cur}${i}: ${COMP_WORDS[i]}"
done
echo "COMPREPLY"
local i
for i in "${COMPREPLY[@]}"; do
echo "${i}"
done
} >> "${log}"
}
complete -F generate_suggestions complete.bash With regular bash completion:
With fzf_bash_completion
|
@lincheney |
I have some bash completions which end up including special characters, but it looks like the tab completion here doesn't quite handle them correctly.
I was able to reproduce the issue I've been running into:
The goal of this is to put the string
\\@today
on the command line so that it passes\@today
to the program when executed.With regular bash completion:
complete.bash <TAB>
generatesabcd efgh ijkl \\@today
complete.bash \<TAB>
autofills\\@today
complete.bash \\<TAB>
autofills\\@today
With fzf_bash_completion:
complete.bash <TAB>
generatesabcd efgh ijkl \\@today
, if I select\\@today
it's entered onto the command line correctlycomplete.bash \<TAB>
autofills\\@today
complete.bash \\<TAB>
autofills\@today
, losing a backslashIf you add another entry with a similar prefix, say
\\@tomorrow
and setFZF_COMPLETION_AUTO_COMMON_PREFIX
andFZF_COMPLETION_AUTO_COMMON_PREFIX_PART
:complete.bash \<TAB>
autofills\\@to
complete.bash \\@to<TAB>
generates\@today \@tomorrow
, losing a backslashcomplete.bash \\<TAB>
autofills\@to
, losing a backslashThe text was updated successfully, but these errors were encountered: