Skip to content

Commit f6a2211

Browse files
committed
refactor(__load_completion): handle backslash always at start of command
Previously, we handled it at the start of the command's _basename_. Even though the backslash doesn't make a practical difference with regards to aliases with paths, it seems more logical and clearer to handle it this way. When invoked as just the basename, this does not change anything.
1 parent d93a6ab commit f6a2211

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

bash_completion

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,6 +2500,14 @@ __load_completion()
25002500
local -a paths
25012501
[[ $cmdname ]] || return 1
25022502
2503+
local backslash=
2504+
if [[ $cmd == \\* ]]; then
2505+
cmd=${cmd:1}
2506+
# If we already have a completion for the "real" command, use it
2507+
$(complete -p "$cmd" 2>/dev/null || echo false) "\\$cmd" && return 0
2508+
backslash=\\
2509+
fi
2510+
25032511
local -a dirs=()
25042512
25052513
# Lookup order:
@@ -2538,14 +2546,6 @@ __load_completion()
25382546
_comp_split -F : paths "${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
25392547
dirs+=("${paths[@]/%//bash-completion/completions}")
25402548
2541-
local backslash=
2542-
if [[ $cmdname == \\* ]]; then
2543-
cmdname=${cmdname:1}
2544-
# If we already have a completion for the "real" command, use it
2545-
$(complete -p "$cmdname" 2>/dev/null || echo false) "\\$cmdname" && return 0
2546-
backslash=\\
2547-
fi
2548-
25492549
# For loading 3rd party completions wrapped in shopt reset
25502550
local IFS=$' \t\n'
25512551

0 commit comments

Comments
 (0)