← Commit list

9809a82b5

Denys Vlasenko
Denys Vlasenko
2018-01-13
SUCCESS Duration: 143s

Subject

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

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash_test/ash-misc/control_char1.right+1 -0
@@ -1,2 +1,3 @@

+b#c
Done:0
shell/ash_test/ash-misc/control_char1.tests+1 -0
@@ -1,2 +1,3 @@
echo 
+echo 'b#c'
echo Done:$?
shell/ash_test/ash-misc/for_with_bslashes.right+1 -0
@@ -5,4 +5,5 @@ b"c
b'c
b$c
b`true`c
+b#c
Zero:0
shell/ash_test/ash-misc/for_with_bslashes.tests+2 -6
@@ -1,9 +1,5 @@
-# UNFIXED BUG.
-# commented-out words contain ^C character.
-# 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'
+# last word contains ^C character.
+for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' 'b#c'
do
echo $a
done
shell/hush.c+5 -0
@@ -5225,6 +5225,11 @@ static struct pipe *parse_stream(char **pstring,
nommu_addchr(&ctx.as_string, ch);
if (ch == '\'')
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);
}
}
shell/hush_test/hush-misc/control_char1.right+1 -0
@@ -1,2 +1,3 @@

+b#c
Done:0
shell/hush_test/hush-misc/control_char1.tests+1 -0
@@ -1,2 +1,3 @@
echo 
+echo 'b#c'
echo Done:$?
shell/hush_test/hush-misc/for_with_bslashes.right+1 -0
@@ -5,4 +5,5 @@ b"c
b'c
b$c
b`true`c
+b#c
Zero:0
shell/hush_test/hush-misc/for_with_bslashes.tests+2 -6
@@ -1,9 +1,5 @@
-# UNFIXED BUG.
-# commented-out words contain ^C character.
-# 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'
+# last word contains ^C character.
+for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' 'b#c'
do
echo $a
done