diff options
author | Kerin Millar <kfm@plushkava.net> | 2024-08-17 19:25:22 +0100 |
---|---|---|
committer | Kerin Millar <kfm@plushkava.net> | 2024-08-22 20:37:46 +0100 |
commit | f60b038e3ae789d01b38eb44ed15dc44ad78bf7c (patch) | |
tree | f73b87abfe704eedae00ece0d15312bd73dc39a3 | |
parent | Optimise trim() for bash where processing the positional parameters (diff) | |
download | gentoo-functions-f60b038e3ae789d01b38eb44ed15dc44ad78bf7c.tar.gz gentoo-functions-f60b038e3ae789d01b38eb44ed15dc44ad78bf7c.tar.bz2 gentoo-functions-f60b038e3ae789d01b38eb44ed15dc44ad78bf7c.zip |
Double quote a ${parameter+word} expansion in defer()
Doing so protects against the following scenario.
$ IFS=e word=1
$ set -x; test ${word+set}
+ test s t
dash: 2: test: s: unexpected operator
Signed-off-by: Kerin Millar <kfm@plushkava.net>
-rw-r--r-- | functions.sh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/functions.sh b/functions.sh index 3dd2969..8180182 100644 --- a/functions.sh +++ b/functions.sh @@ -175,7 +175,7 @@ deref() elif ! trueof_all is_identifier -- "$@"; then _warn_for_args deref "$@" false - elif ! eval "test \${$1+set}"; then + elif ! eval "test \"\${$1+set}\""; then false elif [ "$#" -eq 1 ]; then eval "printf '%s\\n' \"\$$1\"" |