From af30c4b86e20512cbd2cfa861ff8346ed6bd1c3e Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 30 Nov 2013 16:21:15 -0500 Subject: 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 --- sh/functions.sh.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sh') 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;; -- cgit v1.2.3