Codebase list openrc / af30c4b
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> Mike Frysinger 10 years ago
1 changed file(s) with 6 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2323 {
2424 [ -z "$1" ] && return 1
2525
26 # Check the value directly so people can do:
27 # yesno ${VAR}
2628 case "$1" in
2729 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;;
2830 [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;;
2931 esac
3032
33 # Check the value of the var so people can do:
34 # yesno VAR
35 # Note: this breaks when the var contains a double quote.
3136 local value=
32 eval value=\$${1}
37 eval value=\"\$$1\"
3338 case "$value" in
3439 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;;
3540 [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;;