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 18:16:43 +0000 (14:16 -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 7d04167..b5cf861 100644 (file)
@@ -5303,6 +5303,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 1f94181..bccba3e 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 14b2314..194e7db 100644 (file)
@@ -1,4 +1,4 @@
 http://busybox.net
 http://busybox.net_abc
-1
-1
+1 1
+1 1
index 0a63696..48a6782 100755 (executable)
@@ -4,6 +4,6 @@ echo $URL
 echo ${URL}_abc
 
 true
-false; echo $?
+false; echo $? ${?}
 true
-{ false; echo $?; }
+{ false; echo $? ${?}; }
index e772aaa..5e28d2f 100644 (file)
@@ -1,3 +1,2 @@
 hush: syntax error: unterminated ${name}
 hush: syntax error: unterminated ${name}
-hush: syntax error: unterminated ${name}
index e09f433..aea36d6 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 $$