Skip to content

Commit a53a81e

Browse files
committed
fix(secret-tool): protect unset opts[...] from pathname expansions
``unset opts["$word"]'' will be unintendedly expanded to `opts<X>' when $word contains a character <X> and there is a file named `opts<X>'. Even if there is no matching filenames, when `shopt -s failglob' is set, ``unset opts["$word"]'' always fails. We should quote it as "unset 'opts[$word]'". In addition, it is better to specify `-v' option in case that there is a confusing name of a shell function.
1 parent a086857 commit a53a81e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

completions/secret-tool

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ _secret_tool()
3939
search)
4040
local -A opts=([--all]="" [--unlock]="")
4141
for word in "${words[@]:2}"; do
42-
[[ $word ]] && unset opts["$word"]
42+
[[ $word ]] && unset -v 'opts[$word]'
4343
done
4444
COMPREPLY=($(compgen -W '${!opts[@]}' -- "$cur"))
4545
;;

0 commit comments

Comments
 (0)