Skip to content

Commit dd6aa27

Browse files
authored
Merge pull request #1159 from akinomyoga/type-literal-arg
fix: use `--` to pass an arbitrary string to builtins
2 parents 23b8144 + 8998491 commit dd6aa27

27 files changed

+40
-40
lines changed

bash_completion

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ _comp_compgen()
649649
else
650650
_generator=("_comp_compgen_$1")
651651
fi
652-
if ! declare -F "${_generator[0]}" &>/dev/null; then
652+
if ! declare -F -- "${_generator[0]}" &>/dev/null; then
653653
printf 'bash_completion: %s: unrecognized generator `%s'\'' (function %s not found)\n' "$FUNCNAME" "$1" "${_generator[0]}" >&2
654654
return 2
655655
fi
@@ -2765,18 +2765,18 @@ _comp_command_offset()
27652765
else
27662766
_comp_dequote "${COMP_WORDS[0]}" || REPLY=${COMP_WORDS[0]}
27672767
local cmd=$REPLY compcmd=$REPLY
2768-
local cspec=$(complete -p "$cmd" 2>/dev/null)
2768+
local cspec=$(complete -p -- "$cmd" 2>/dev/null)
27692769

27702770
# If we have no completion for $cmd yet, see if we have for basename
27712771
if [[ ! $cspec && $cmd == */* ]]; then
2772-
cspec=$(complete -p "${cmd##*/}" 2>/dev/null)
2772+
cspec=$(complete -p -- "${cmd##*/}" 2>/dev/null)
27732773
[[ $cspec ]] && compcmd=${cmd##*/}
27742774
fi
27752775
# If still nothing, just load it for the basename
27762776
if [[ ! $cspec ]]; then
27772777
compcmd=${cmd##*/}
27782778
_comp_load -D -- "$compcmd"
2779-
cspec=$(complete -p "$compcmd" 2>/dev/null)
2779+
cspec=$(complete -p -- "$compcmd" 2>/dev/null)
27802780
fi
27812781

27822782
local retry_count=0
@@ -2809,7 +2809,7 @@ _comp_command_offset()
28092809
# state of COMPREPLY is discarded.
28102810
COMPREPLY=()
28112811

2812-
cspec=$(complete -p "$compcmd" 2>/dev/null)
2812+
cspec=$(complete -p -- "$compcmd" 2>/dev/null)
28132813

28142814
# Note: When completion spec is removed after 124, we
28152815
# do not generate any completions including the default
@@ -3147,7 +3147,7 @@ _comp_load()
31473147
if [[ $cmd == \\* ]]; then
31483148
cmd=${cmd:1}
31493149
# If we already have a completion for the "real" command, use it
3150-
$(complete -p "$cmd" 2>/dev/null || echo false) "\\$cmd" && return 0
3150+
$(complete -p -- "$cmd" 2>/dev/null || echo false) "\\$cmd" && return 0
31513151
backslash=\\
31523152
fi
31533153
@@ -3222,18 +3222,18 @@ _comp_load()
32223222
elif [[ -e $compfile ]] && . "$compfile" "$cmd" "$@"; then
32233223
# At least $cmd is expected to have a completion set when
32243224
# we return successfully; see if it already does
3225-
if compspec=$(complete -p "$cmd" 2>/dev/null); then
3225+
if compspec=$(complete -p -- "$cmd" 2>/dev/null); then
32263226
# $cmd is the case in which we do backslash processing
32273227
[[ $backslash ]] && eval "$compspec \"\$backslash\$cmd\""
32283228
# If invoked without path, that one should be set, too
32293229
# ...but let's not overwrite an existing one, if any
32303230
[[ $origcmd != */* ]] &&
3231-
! complete -p "$origcmd" &>/dev/null &&
3231+
! complete -p -- "$origcmd" &>/dev/null &&
32323232
eval "$compspec \"\$origcmd\""
32333233
return 0
32343234
fi
32353235
# If not, see if we got one for $cmdname
3236-
if [[ $cmdname != "$cmd" ]] && compspec=$(complete -p "$cmdname" 2>/dev/null); then
3236+
if [[ $cmdname != "$cmd" ]] && compspec=$(complete -p -- "$cmdname" 2>/dev/null); then
32373237
# Use that for $cmd too, if we have a full path to it
32383238
[[ $cmd == /* ]] && eval "$compspec \"\$cmd\""
32393239
return 0
@@ -3281,7 +3281,7 @@ _comp_xfunc()
32813281
local xfunc_name=$2
32823282
[[ $xfunc_name == _* ]] ||
32833283
xfunc_name=_comp_xfunc_${1//[^a-zA-Z0-9_]/_}_$xfunc_name
3284-
declare -F "$xfunc_name" &>/dev/null || _comp_load "$1"
3284+
declare -F -- "$xfunc_name" &>/dev/null || _comp_load -- "$1"
32853285
"$xfunc_name" "${@:3}"
32863286
}
32873287

completions/_nox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# This serves as a fallback in case the completion is not installed otherwise.
55

66
eval -- "$(
7-
bin_path=$(type -P "$1" 2>/dev/null | command sed 's,/[^/]*$,,')
8-
[[ $bin_path ]] && PATH=$bin_path${PATH:+:$PATH}
7+
pathcmd=$(type -P -- "$1" 2>/dev/null | command sed 's,/[^/]*$,,')
8+
[[ $pathcmd ]] && PATH=$pathcmd${PATH:+:$PATH}
99
register-python-argcomplete --shell bash "$1" 2>/dev/null ||
1010
register-python-argcomplete3 --shell bash "$1" 2>/dev/null
1111
)"

completions/add_members

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _comp_cmd_add_members()
2424
else
2525
# Prefer `list_lists` in the same dir as command
2626
local pathcmd
27-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
27+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
2828
_comp_xfunc list_lists mailman_lists
2929
fi
3030

completions/apt-get

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ _comp_cmd_apt_get()
3333
source)
3434
# Prefer `apt-cache` in the same dir as command
3535
local pathcmd
36-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
36+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
3737
_comp_compgen -x apt-cache packages
3838
_comp_compgen -a split -- "$(apt-cache dumpavail |
3939
_comp_awk '$1 == "Source:" { print $2 }' | sort -u)"
@@ -79,7 +79,7 @@ _comp_cmd_apt_get()
7979
--target-release | --default-release | -${noargopts}t)
8080
# Prefer `apt-cache` in the same dir as command
8181
local pathcmd
82-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
82+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
8383
_comp_compgen_split -- "$(apt-cache policy | command sed -ne \
8484
's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')"
8585
return

completions/arch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _comp_have_command mailmanctl &&
3434
1)
3535
# Prefer `list_lists` in the same dir as command
3636
local pathcmd
37-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
37+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
3838
_comp_compgen -x list_lists mailman_lists
3939
;;
4040
2)

completions/change_pw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _comp_cmd_change_pw()
99
-l | --listname)
1010
# Prefer `list_lists` in the same dir as command
1111
local pathcmd
12-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
12+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
1313
_comp_compgen -x list_lists mailman_lists
1414
return
1515
;;

completions/check_db

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _comp_cmd_check_db()
1010
else
1111
# Prefer `list_lists` in the same dir as command
1212
local pathcmd
13-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
13+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
1414
_comp_compgen -x list_lists mailman_lists
1515
fi
1616

completions/clone_member

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _comp_cmd_clone_member()
99
-l | --listname)
1010
# Prefer `list_lists` in the same dir as command
1111
local pathcmd
12-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
12+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
1313
_comp_compgen -x list_lists mailman_lists
1414
return
1515
;;

completions/config_list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ _comp_cmd_config_list()
2020
else
2121
# Prefer `list_lists` in the same dir as command
2222
local pathcmd
23-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
23+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
2424
_comp_xfunc list_lists mailman_lists
2525
fi
2626

completions/find_member

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _comp_cmd_find_member()
99
-l | -x | --listname | --exclude)
1010
# Prefer `list_lists` in the same dir as command
1111
local pathcmd
12-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
12+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
1313
_comp_compgen -x list_lists mailman_lists
1414
return
1515
;;

0 commit comments

Comments
 (0)