aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-06-01 14:09:09 -0400
committerMike Frysinger <vapier@gentoo.org>2009-06-01 16:01:28 -0400
commitb6bca7703bbe6aacec0bda964c82fad389a02b69 (patch)
tree59696310ddbfbc919c99aca7704243d5a55773d8
parent77508d70bfa9c50477479af176ff41e9443d4f67 (diff)
downloadbusybox-w32-b6bca7703bbe6aacec0bda964c82fad389a02b69.tar.gz
busybox-w32-b6bca7703bbe6aacec0bda964c82fad389a02b69.tar.bz2
busybox-w32-b6bca7703bbe6aacec0bda964c82fad389a02b69.zip
hush: add support for special vars in braces
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>
-rw-r--r--shell/hush.c3
-rw-r--r--shell/hush_test/hush-vars/param_expand_indicate_error.right1
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_indicate_error.tests2
-rw-r--r--shell/hush_test/hush-vars/var1.right4
-rwxr-xr-xshell/hush_test/hush-vars/var1.tests4
-rw-r--r--shell/hush_test/hush-vars/var3.right1
-rwxr-xr-xshell/hush_test/hush-vars/var3.tests2
7 files changed, 9 insertions, 8 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 735cb4cee..d067e919d 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -5272,6 +5272,9 @@ static int handle_dollar(o_string *as_string,
5272 all_digits = true; 5272 all_digits = true;
5273 goto char_ok; 5273 goto char_ok;
5274 } 5274 }
5275 /* They're being verbose and doing ${?} */
5276 if (i_peek(input) == '}' && strchr("$!?#*@_", ch))
5277 goto char_ok;
5275 } 5278 }
5276 5279
5277 if (expansion < 2 5280 if (expansion < 2
diff --git a/shell/hush_test/hush-vars/param_expand_indicate_error.right b/shell/hush_test/hush-vars/param_expand_indicate_error.right
index ec4908c35..590bb2001 100644
--- a/shell/hush_test/hush-vars/param_expand_indicate_error.right
+++ b/shell/hush_test/hush-vars/param_expand_indicate_error.right
@@ -1,5 +1,4 @@
1hush: syntax error: unterminated ${name} 1hush: syntax error: unterminated ${name}
2hush: syntax error: unterminated ${name}
30 20
40 30
5_ 4_
diff --git a/shell/hush_test/hush-vars/param_expand_indicate_error.tests b/shell/hush_test/hush-vars/param_expand_indicate_error.tests
index 1f94181a9..bccba3e1b 100755
--- a/shell/hush_test/hush-vars/param_expand_indicate_error.tests
+++ b/shell/hush_test/hush-vars/param_expand_indicate_error.tests
@@ -1,7 +1,7 @@
1# do all of these in subshells since it's supposed to error out 1# do all of these in subshells since it's supposed to error out
2 2
3# first try some invalid patterns 3# first try some invalid patterns
4"$THIS_SH" -c 'echo ${?}' 4#"$THIS_SH" -c 'echo ${?}' -- this is valid as it's the same as $?
5"$THIS_SH" -c 'echo ${:?}' 5"$THIS_SH" -c 'echo ${:?}'
6 6
7# then some funky ones 7# then some funky ones
diff --git a/shell/hush_test/hush-vars/var1.right b/shell/hush_test/hush-vars/var1.right
index 14b2314d9..194e7dbe2 100644
--- a/shell/hush_test/hush-vars/var1.right
+++ b/shell/hush_test/hush-vars/var1.right
@@ -1,4 +1,4 @@
1http://busybox.net 1http://busybox.net
2http://busybox.net_abc 2http://busybox.net_abc
31 31 1
41 41 1
diff --git a/shell/hush_test/hush-vars/var1.tests b/shell/hush_test/hush-vars/var1.tests
index 0a63696c9..48a6782ba 100755
--- a/shell/hush_test/hush-vars/var1.tests
+++ b/shell/hush_test/hush-vars/var1.tests
@@ -4,6 +4,6 @@ echo $URL
4echo ${URL}_abc 4echo ${URL}_abc
5 5
6true 6true
7false; echo $? 7false; echo $? ${?}
8true 8true
9{ false; echo $?; } 9{ false; echo $? ${?}; }
diff --git a/shell/hush_test/hush-vars/var3.right b/shell/hush_test/hush-vars/var3.right
index e772aaada..5e28d2fab 100644
--- a/shell/hush_test/hush-vars/var3.right
+++ b/shell/hush_test/hush-vars/var3.right
@@ -1,3 +1,2 @@
1hush: syntax error: unterminated ${name} 1hush: syntax error: unterminated ${name}
2hush: syntax error: unterminated ${name} 2hush: syntax error: unterminated ${name}
3hush: syntax error: unterminated ${name}
diff --git a/shell/hush_test/hush-vars/var3.tests b/shell/hush_test/hush-vars/var3.tests
index e09f43317..aea36d62d 100755
--- a/shell/hush_test/hush-vars/var3.tests
+++ b/shell/hush_test/hush-vars/var3.tests
@@ -1,4 +1,4 @@
1# reject invalid vars 1# reject invalid vars
2"$THIS_SH" -c 'echo ${1q}' 2"$THIS_SH" -c 'echo ${1q}'
3"$THIS_SH" -c 'echo ${&}' 3"$THIS_SH" -c 'echo ${&}'
4"$THIS_SH" -c 'echo ${$}' 4#"$THIS_SH" -c 'echo ${$}' -- this is valid as it's the same as $$