hush: add support for special vars in braces
authorMike Frysinger <vapier@gentoo.org>
Mon, 1 Jun 2009 18:09:09 +0000 (14:09 -0400)
committerMike Frysinger <vapier@gentoo.org>
Mon, 1 Jun 2009 20:01:28 +0000 (16:01 -0400)
Some people like to use ${?} rather than $?, so make sure we support all
the special single char vars that use this form.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
shell/hush.c
shell/hush_test/hush-vars/param_expand_indicate_error.right
shell/hush_test/hush-vars/param_expand_indicate_error.tests
shell/hush_test/hush-vars/var1.right
shell/hush_test/hush-vars/var1.tests
shell/hush_test/hush-vars/var3.right
shell/hush_test/hush-vars/var3.tests

index 735cb4cee9b16b6bd9e953845acad298dbb8c625..d067e919d3c5ce99ac94d92481cb6093ec6cf093 100644 (file)
@@ -5272,6 +5272,9 @@ static int handle_dollar(o_string *as_string,
                                        all_digits = true;
                                        goto char_ok;
                                }
+                               /* They're being verbose and doing ${?} */
+                               if (i_peek(input) == '}' && strchr("$!?#*@_", ch))
+                                       goto char_ok;
                        }
 
                        if (expansion < 2
index ec4908c3584427455d73908f4e851ce169ab0d31..590bb2001a36c904765d269cb883ef54a1c0e1f1 100644 (file)
@@ -1,5 +1,4 @@
 hush: syntax error: unterminated ${name}
-hush: syntax error: unterminated ${name}
 0
 0
 _
index 1f94181a96bac5a3e06e09452cdd1c2f93c2e9ef..bccba3e1b6bac956121feec4b45ea9304efe4159 100755 (executable)
@@ -1,7 +1,7 @@
 # do all of these in subshells since it's supposed to error out
 
 # first try some invalid patterns
-"$THIS_SH" -c 'echo ${?}'
+#"$THIS_SH" -c 'echo ${?}' -- this is valid as it's the same as $?
 "$THIS_SH" -c 'echo ${:?}'
 
 # then some funky ones
index 14b2314d95f4dbadc945b3e43276aa89c2103627..194e7dbe266531ce75b33d76afa0084b10da4919 100644 (file)
@@ -1,4 +1,4 @@
 http://busybox.net
 http://busybox.net_abc
-1
-1
+1 1
+1 1
index 0a63696c9fad81957f1ad92a6d1554ac5a43ebeb..48a6782bafc7c7cdac37c131bc9e1945b9118476 100755 (executable)
@@ -4,6 +4,6 @@ echo $URL
 echo ${URL}_abc
 
 true
-false; echo $?
+false; echo $? ${?}
 true
-{ false; echo $?; }
+{ false; echo $? ${?}; }
index e772aaadabc4727cfff85a7449c3eaea7c9748bf..5e28d2fabb1fa86d21750aa9a371eb8f41f7b880 100644 (file)
@@ -1,3 +1,2 @@
 hush: syntax error: unterminated ${name}
 hush: syntax error: unterminated ${name}
-hush: syntax error: unterminated ${name}
index e09f4331780f7a29215f9250cbf428db36201bc7..aea36d62d535969f36779936352a46ca8e66251a 100755 (executable)
@@ -1,4 +1,4 @@
 # reject invalid vars
 "$THIS_SH" -c 'echo ${1q}'
 "$THIS_SH" -c 'echo ${&}'
-"$THIS_SH" -c 'echo ${$}'
+#"$THIS_SH" -c 'echo ${$}' -- this is valid as it's the same as $$