aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-06-12 12:58:20 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-06-12 12:58:20 +0000
commit76db5adbf70046dec92309a9785da08d1acf4e9d (patch)
tree17af552a8734448ca55f501e3df8e3e2ac018e00 /shell
parentbd1aeeb850e441e3fa4f9e1f8aedd804a48b9cb1 (diff)
downloadbusybox-w32-76db5adbf70046dec92309a9785da08d1acf4e9d.tar.gz
busybox-w32-76db5adbf70046dec92309a9785da08d1acf4e9d.tar.bz2
busybox-w32-76db5adbf70046dec92309a9785da08d1acf4e9d.zip
hush: fix for nested $()s with escapes + testsuite
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c12
-rwxr-xr-xshell/hush_test/hush-psubst/tick3.tests1
-rw-r--r--shell/hush_test/hush-psubst/tick4.right7
-rwxr-xr-xshell/hush_test/hush-psubst/tick4.tests7
4 files changed, 25 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 735526a1d..77a305191 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -3498,6 +3498,13 @@ static void add_till_closing_curly_brace(o_string *dest, struct in_str *input)
3498 o_addqchr(dest, ch, 1); 3498 o_addqchr(dest, ch, 1);
3499 continue; 3499 continue;
3500 } 3500 }
3501 if (ch == '\\') { /* \x. Copy verbatim. Important for \(, \) */
3502 ch = i_getch(input);
3503 if (ch == EOF)
3504 break;
3505 o_addqchr(dest, ch, 1);
3506 continue;
3507 }
3501 } 3508 }
3502} 3509}
3503#endif /* ENABLE_HUSH_TICK */ 3510#endif /* ENABLE_HUSH_TICK */
@@ -3556,13 +3563,16 @@ static int handle_dollar(o_string *dest, struct in_str *input)
3556 o_addchr(dest, SPECIAL_VAR_SYMBOL); 3563 o_addchr(dest, SPECIAL_VAR_SYMBOL);
3557 break; 3564 break;
3558#if ENABLE_HUSH_TICK 3565#if ENABLE_HUSH_TICK
3559 case '(': 3566 case '(': {
3567 //int pos = dest->length;
3560 i_getch(input); 3568 i_getch(input);
3561 o_addchr(dest, SPECIAL_VAR_SYMBOL); 3569 o_addchr(dest, SPECIAL_VAR_SYMBOL);
3562 o_addchr(dest, quote_mask | '`'); 3570 o_addchr(dest, quote_mask | '`');
3563 add_till_closing_curly_brace(dest, input); 3571 add_till_closing_curly_brace(dest, input);
3572 //bb_error_msg("RES '%s'", dest->data + pos);
3564 o_addchr(dest, SPECIAL_VAR_SYMBOL); 3573 o_addchr(dest, SPECIAL_VAR_SYMBOL);
3565 break; 3574 break;
3575 }
3566#endif 3576#endif
3567 case '-': 3577 case '-':
3568 case '_': 3578 case '_':
diff --git a/shell/hush_test/hush-psubst/tick3.tests b/shell/hush_test/hush-psubst/tick3.tests
index 97b45e4b4..2b055bb69 100755
--- a/shell/hush_test/hush-psubst/tick3.tests
+++ b/shell/hush_test/hush-psubst/tick3.tests
@@ -1,4 +1,3 @@
1#!/bin/sh
2TEST=Q 1TEST=Q
3# \` is special 2# \` is special
4echo `echo '\'TEST\`echo ZZ\`BEST` 3echo `echo '\'TEST\`echo ZZ\`BEST`
diff --git a/shell/hush_test/hush-psubst/tick4.right b/shell/hush_test/hush-psubst/tick4.right
new file mode 100644
index 000000000..d8030eafd
--- /dev/null
+++ b/shell/hush_test/hush-psubst/tick4.right
@@ -0,0 +1,7 @@
1(TEST) BEST
2TEST) BEST
3((TEST) BEST
4)
5abc
6a)c
7OK: 0
diff --git a/shell/hush_test/hush-psubst/tick4.tests b/shell/hush_test/hush-psubst/tick4.tests
new file mode 100755
index 000000000..f2305fb3d
--- /dev/null
+++ b/shell/hush_test/hush-psubst/tick4.tests
@@ -0,0 +1,7 @@
1echo $(echo '(TEST)' BEST)
2echo $(echo 'TEST)' BEST)
3echo $(echo \(\(TEST\) BEST)
4echo $(echo \))
5echo $(echo a"`echo "b"`"c )
6echo $(echo a"`echo ")"`"c )
7echo OK: $?