hush: fix raw ^C handlisg in single-quoted strings

function                                             old     new   delta
parse_stream                                        2719    2754     +35

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-01-13 19:14:27 +01:00
parent 6606c519ef
commit 9809a82b59
9 changed files with 15 additions and 12 deletions

View File

@ -1,2 +1,3 @@
 
b#c
Done:0 Done:0

View File

@ -1,2 +1,3 @@
echo  echo 
echo 'b#c'
echo Done:$? echo Done:$?

View File

@ -5,4 +5,5 @@ b"c
b'c b'c
b$c b$c
b`true`c b`true`c
b#c
Zero:0 Zero:0

View File

@ -1,9 +1,5 @@
# UNFIXED BUG. # last word contains ^C character.
# commented-out words contain ^C character. for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' 'b#c'
# It's a SPECIAL_VAR_SYMBOL, for now hush does not escape it.
# When it is fixed, update this test.
for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' ### 'b#c'
do do
echo $a echo $a
done done

View File

@ -5225,6 +5225,11 @@ static struct pipe *parse_stream(char **pstring,
nommu_addchr(&ctx.as_string, ch); nommu_addchr(&ctx.as_string, ch);
if (ch == '\'') if (ch == '\'')
break; break;
if (ch == SPECIAL_VAR_SYMBOL) {
/* Convert raw ^C to corresponding special variable reference */
o_addchr(&dest, SPECIAL_VAR_SYMBOL);
o_addchr(&dest, SPECIAL_VAR_QUOTED_SVS);
}
o_addqchr(&dest, ch); o_addqchr(&dest, ch);
} }
} }

View File

@ -1,2 +1,3 @@
 
b#c
Done:0 Done:0

View File

@ -1,2 +1,3 @@
echo  echo 
echo 'b#c'
echo Done:$? echo Done:$?

View File

@ -5,4 +5,5 @@ b"c
b'c b'c
b$c b$c
b`true`c b`true`c
b#c
Zero:0 Zero:0

View File

@ -1,9 +1,5 @@
# UNFIXED BUG. # last word contains ^C character.
# commented-out words contain ^C character. for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' 'b#c'
# It's a SPECIAL_VAR_SYMBOL, for now hush does not escape it.
# When it is fixed, update this test.
for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' ### 'b#c'
do do
echo $a echo $a
done done