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>
This commit is contained in:
Mike Frysinger 2013-11-30 16:21:15 -05:00
parent 6965d85f2e
commit af30c4b86e

View File

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