hush: fix for nested $()s with escapes + testsuite
This commit is contained in:
parent
bd1aeeb850
commit
76db5adbf7
12
shell/hush.c
12
shell/hush.c
@ -3498,6 +3498,13 @@ static void add_till_closing_curly_brace(o_string *dest, struct in_str *input)
|
||||
o_addqchr(dest, ch, 1);
|
||||
continue;
|
||||
}
|
||||
if (ch == '\\') { /* \x. Copy verbatim. Important for \(, \) */
|
||||
ch = i_getch(input);
|
||||
if (ch == EOF)
|
||||
break;
|
||||
o_addqchr(dest, ch, 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_HUSH_TICK */
|
||||
@ -3556,13 +3563,16 @@ static int handle_dollar(o_string *dest, struct in_str *input)
|
||||
o_addchr(dest, SPECIAL_VAR_SYMBOL);
|
||||
break;
|
||||
#if ENABLE_HUSH_TICK
|
||||
case '(':
|
||||
case '(': {
|
||||
//int pos = dest->length;
|
||||
i_getch(input);
|
||||
o_addchr(dest, SPECIAL_VAR_SYMBOL);
|
||||
o_addchr(dest, quote_mask | '`');
|
||||
add_till_closing_curly_brace(dest, input);
|
||||
//bb_error_msg("RES '%s'", dest->data + pos);
|
||||
o_addchr(dest, SPECIAL_VAR_SYMBOL);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case '-':
|
||||
case '_':
|
||||
|
@ -1,4 +1,3 @@
|
||||
#!/bin/sh
|
||||
TEST=Q
|
||||
# \` is special
|
||||
echo `echo '\'TEST\`echo ZZ\`BEST`
|
||||
|
7
shell/hush_test/hush-psubst/tick4.right
Normal file
7
shell/hush_test/hush-psubst/tick4.right
Normal file
@ -0,0 +1,7 @@
|
||||
(TEST) BEST
|
||||
TEST) BEST
|
||||
((TEST) BEST
|
||||
)
|
||||
abc
|
||||
a)c
|
||||
OK: 0
|
7
shell/hush_test/hush-psubst/tick4.tests
Executable file
7
shell/hush_test/hush-psubst/tick4.tests
Executable file
@ -0,0 +1,7 @@
|
||||
echo $(echo '(TEST)' BEST)
|
||||
echo $(echo 'TEST)' BEST)
|
||||
echo $(echo \(\(TEST\) BEST)
|
||||
echo $(echo \))
|
||||
echo $(echo a"`echo "b"`"c )
|
||||
echo $(echo a"`echo ")"`"c )
|
||||
echo OK: $?
|
Loading…
Reference in New Issue
Block a user