1 |
commit: af30c4b86e20512cbd2cfa861ff8346ed6bd1c3e |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Nov 30 21:21:15 2013 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Nov 30 21:33:31 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=af30c4b8 |
7 |
|
8 |
functions.sh: yesno: (mostly) fix eval logic |
9 |
|
10 |
We need to quote the expansion. |
11 |
|
12 |
X-Gentoo-Bug: 475032 |
13 |
X-Gentoo-Bug: https://bugs.gentoo.org/475032 |
14 |
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> |
15 |
|
16 |
--- |
17 |
sh/functions.sh.in | 7 ++++++- |
18 |
1 file changed, 6 insertions(+), 1 deletion(-) |
19 |
|
20 |
diff --git a/sh/functions.sh.in b/sh/functions.sh.in |
21 |
index 52a8ae7..e4e69eb 100644 |
22 |
--- a/sh/functions.sh.in |
23 |
+++ b/sh/functions.sh.in |
24 |
@@ -24,13 +24,18 @@ yesno() |
25 |
{ |
26 |
[ -z "$1" ] && return 1 |
27 |
|
28 |
+ # Check the value directly so people can do: |
29 |
+ # yesno ${VAR} |
30 |
case "$1" in |
31 |
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; |
32 |
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; |
33 |
esac |
34 |
|
35 |
+ # Check the value of the var so people can do: |
36 |
+ # yesno VAR |
37 |
+ # Note: this breaks when the var contains a double quote. |
38 |
local value= |
39 |
- eval value=\$${1} |
40 |
+ eval value=\"\$$1\" |
41 |
case "$value" in |
42 |
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; |
43 |
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; |