diff options
author | Mike Frysinger <vapier@gentoo.org> | 2013-11-30 16:21:15 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2013-11-30 16:33:31 -0500 |
commit | af30c4b86e20512cbd2cfa861ff8346ed6bd1c3e (patch) | |
tree | c04c41ef1a3c63a44a91aeeaac627ed115768317 /sh | |
parent | 6965d85f2efb4e1d7b37e04af890b715091fe3d9 (diff) |
functions.sh: yesno: (mostly) fix eval logic
We need to quote the expansion.
X-Gentoo-Bug: 475032
X-Gentoo-Bug: https://bugs.gentoo.org/475032
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'sh')
-rw-r--r-- | sh/functions.sh.in | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sh/functions.sh.in b/sh/functions.sh.in index 52a8ae77..e4e69eb7 100644 --- a/sh/functions.sh.in +++ b/sh/functions.sh.in @@ -24,13 +24,18 @@ yesno() { [ -z "$1" ] && return 1 + # Check the value directly so people can do: + # yesno ${VAR} case "$1" in [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; esac + # Check the value of the var so people can do: + # yesno VAR + # Note: this breaks when the var contains a double quote. local value= - eval value=\$${1} + eval value=\"\$$1\" case "$value" in [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; |