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
23 | 23 | { |
24 | 24 | [ -z "$1" ] && return 1 |
25 | 25 | |
26 | # Check the value directly so people can do: | |
27 | # yesno ${VAR} | |
26 | 28 | case "$1" in |
27 | 29 | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; |
28 | 30 | [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; |
29 | 31 | esac |
30 | 32 | |
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. | |
31 | 36 | local value= |
32 | eval value=\$${1} | |
37 | eval value=\"\$$1\" | |
33 | 38 | case "$value" in |
34 | 39 | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; |
35 | 40 | [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; |