Skip to content

Commit 8795ca9

Browse files
committed
fix: use pathcmd=$(type -P -- "$1") for arbitrary cmds
If the command name starts with `-`, `type` is confused and tries to parse it as an option to `type`. In the current setup, the option starting with `-` does not happen because we do not set up the completion settings for such command names, but it is better to put them on a safe side.
1 parent 350b1b7 commit 8795ca9

25 files changed

+27
-27
lines changed

completions/_nox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This serves as a fallback in case the completion is not installed otherwise.
55

66
eval -- "$(
7-
pathcmd=$(type -P "$1" 2>/dev/null | command sed 's,/[^/]*$,,')
7+
pathcmd=$(type -P -- "$1" 2>/dev/null | command sed 's,/[^/]*$,,')
88
[[ $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

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
;;

completions/inject

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _comp_cmd_inject()
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
;;

0 commit comments

Comments
 (0)