diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-06-01 14:09:09 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-06-01 16:01:28 -0400 |
commit | b6bca7703bbe6aacec0bda964c82fad389a02b69 (patch) | |
tree | 59696310ddbfbc919c99aca7704243d5a55773d8 | |
parent | 77508d70bfa9c50477479af176ff41e9443d4f67 (diff) | |
download | busybox-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.c | 3 | ||||
-rw-r--r-- | shell/hush_test/hush-vars/param_expand_indicate_error.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-vars/param_expand_indicate_error.tests | 2 | ||||
-rw-r--r-- | shell/hush_test/hush-vars/var1.right | 4 | ||||
-rwxr-xr-x | shell/hush_test/hush-vars/var1.tests | 4 | ||||
-rw-r--r-- | shell/hush_test/hush-vars/var3.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-vars/var3.tests | 2 |
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 @@ | |||
1 | hush: syntax error: unterminated ${name} | 1 | hush: syntax error: unterminated ${name} |
2 | hush: syntax error: unterminated ${name} | ||
3 | 0 | 2 | 0 |
4 | 0 | 3 | 0 |
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 @@ | |||
1 | http://busybox.net | 1 | http://busybox.net |
2 | http://busybox.net_abc | 2 | http://busybox.net_abc |
3 | 1 | 3 | 1 1 |
4 | 1 | 4 | 1 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 | |||
4 | echo ${URL}_abc | 4 | echo ${URL}_abc |
5 | 5 | ||
6 | true | 6 | true |
7 | false; echo $? | 7 | false; echo $? ${?} |
8 | true | 8 | true |
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 @@ | |||
1 | hush: syntax error: unterminated ${name} | 1 | hush: syntax error: unterminated ${name} |
2 | hush: syntax error: unterminated ${name} | 2 | hush: syntax error: unterminated ${name} |
3 | hush: 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 $$ |