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:
parent
6965d85f2e
commit
af30c4b86e
@ -24,13 +24,18 @@ yesno()
|
|||||||
{
|
{
|
||||||
[ -z "$1" ] && return 1
|
[ -z "$1" ] && return 1
|
||||||
|
|
||||||
|
# Check the value directly so people can do:
|
||||||
|
# yesno ${VAR}
|
||||||
case "$1" in
|
case "$1" in
|
||||||
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;;
|
[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;;
|
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;;
|
||||||
esac
|
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=
|
local value=
|
||||||
eval value=\$${1}
|
eval value=\"\$$1\"
|
||||||
case "$value" in
|
case "$value" in
|
||||||
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;;
|
[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;;
|
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;;
|
||||||
|
Loading…
Reference in New Issue
Block a user