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

completions/list_admins

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _comp_cmd_list_admins()
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/list_members

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ _comp_cmd_list_members()
2828
else
2929
# Prefer `list_lists` in the same dir as command
3030
local pathcmd
31-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
31+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
3232
_comp_compgen -x list_lists mailman_lists
3333
fi
3434

completions/list_owners

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _comp_cmd_list_owners()
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/mysql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _comp_cmd_mysql()
2424

2525
# Prefer `mysqlshow` in the same dir as the command
2626
local pathcmd
27-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
27+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
2828

2929
local noargopts='!(-*|*[uDhSPeI]*)'
3030
# shellcheck disable=SC2254

completions/newlist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ _comp_cmd_newlist()
1919
else
2020
# Prefer `list_lists` in the same dir as command
2121
local pathcmd
22-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
22+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
2323
_comp_compgen -x list_lists mailman_lists
2424
fi
2525
} &&

completions/perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ _comp_cmd_perldoc()
107107

108108
# Prefer `perl` in the same dir in utility functions
109109
local pathcmd
110-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
110+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
111111

112112
case $prev in
113113
-*[hVnoMwL])

completions/pydoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _comp_cmd_pydoc()
2525
if ! _comp_looks_like_path "$cur"; then
2626
# Prefer python in the same dir for resolving modules
2727
local pathcmd
28-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
28+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
2929
_comp_compgen -ax python modules
3030
fi
3131

completions/remove_members

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ _comp_cmd_remove_members()
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_compgen -x list_lists mailman_lists
2525
fi
2626

completions/rmlist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _comp_cmd_rmlist()
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/rpm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ _comp_cmd_rpmbuild()
262262
--target | --eval | -${noargopts}E | --buildpolicy)
263263
# Prefer `rpm` in the same dir in utility functions
264264
local pathcmd
265-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
265+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
266266
;;&
267267
--target)
268268
_comp_cmd_rpm__buildarchs

completions/ssh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ _comp_cmd_sftp()
404404

405405
# Prefer `ssh` from same dir for resolving options, etc
406406
local pathcmd
407-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
407+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
408408

409409
_comp_xfunc_ssh_compgen_suboption_check && return
410410

@@ -556,7 +556,7 @@ _comp_cmd_scp()
556556

557557
# Prefer `ssh` from same dir for resolving options, remote files, etc
558558
local pathcmd
559-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
559+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
560560

561561
_comp_xfunc_ssh_compgen_suboption_check && {
562562
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/%/ }")

completions/ssh-copy-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _comp_cmd_ssh_copy_id()
77

88
# Prefer `ssh` from same dir for resolving options, etc
99
local pathcmd
10-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
10+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
1111

1212
_comp_compgen -x ssh suboption_check && return
1313

completions/ssh-keygen

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ _comp_cmd_ssh_keygen()
101101
-*t)
102102
# Prefer `ssh` from same dir for resolving options, etc
103103
local pathcmd protocols
104-
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
104+
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
105105
_comp_compgen -v protocols -x ssh query protocol-version
106106
local types='dsa ecdsa ecdsa-sk ed25519 ed25519-sk rsa'
107107
if [[ ${protocols[*]} == *1* ]]; then

completions/sync_members

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _comp_cmd_sync_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_compgen -x list_lists mailman_lists
2929
fi
3030

completions/withlist

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

0 commit comments

Comments
 (0)