summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-03 02:15:18 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-03 02:15:18 +0200
commite19e1935a33b117e2ee6daf9b2d79c00603333c7 (patch)
tree8154fc2bfedd1fccb7ed1c0b7b2fff2e57f36e4e /shell
parentb1cfc453760b3b3b81bb3217f68074a98c96084b (diff)
downloadbusybox-w32-e19e1935a33b117e2ee6daf9b2d79c00603333c7.tar.gz
busybox-w32-e19e1935a33b117e2ee6daf9b2d79c00603333c7.tar.bz2
busybox-w32-e19e1935a33b117e2ee6daf9b2d79c00603333c7.zip
hush: fix \<newline> handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c28
-rw-r--r--shell/hush_test/hush-parsing/escape4.right2
-rwxr-xr-xshell/hush_test/hush-parsing/escape4.tests6
-rwxr-xr-x[-rw-r--r--]shell/hush_test/hush-parsing/group1.tests0
4 files changed, 22 insertions, 14 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 255caef01..c6e940548 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -50,14 +50,9 @@
50 * 50 *
51 * TODOs: 51 * TODOs:
52 * grep for "TODO" and fix (some of them are easy) 52 * grep for "TODO" and fix (some of them are easy)
53 * change { and } from special chars to reserved words
54 * $var refs in function do not pick up values set by "var=val func" 53 * $var refs in function do not pick up values set by "var=val func"
55 * builtins: ulimit 54 * builtins: ulimit
56 * follow IFS rules more precisely, including update semantics 55 * follow IFS rules more precisely, including update semantics
57 * figure out what to do with backslash-newline
58 * continuation lines, both explicit and implicit - done?
59 * separate job control from interactiveness
60 * (testcase: booting with init=/bin/hush does not show prompt (2009-04))
61 * 56 *
62 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 57 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
63 */ 58 */
@@ -5347,10 +5342,12 @@ static int parse_stream_dquoted(o_string *as_string,
5347 * $, `, ", \, or <newline>. A double quote may be quoted 5342 * $, `, ", \, or <newline>. A double quote may be quoted
5348 * within double quotes by preceding it with a backslash. 5343 * within double quotes by preceding it with a backslash.
5349 */ 5344 */
5350 if (strchr("$`\"\\", next) != NULL) { 5345 if (strchr("$`\"\\\n", next) != NULL) {
5351 ch = i_getch(input); 5346 ch = i_getch(input);
5352 o_addqchr(dest, ch); 5347 if (ch != '\n') {
5353 nommu_addchr(as_string, ch); 5348 o_addqchr(dest, ch);
5349 nommu_addchr(as_string, ch);
5350 }
5354 } else { 5351 } else {
5355 o_addqchr(dest, '\\'); 5352 o_addqchr(dest, '\\');
5356 nommu_addchr(as_string, '\\'); 5353 nommu_addchr(as_string, '\\');
@@ -5677,13 +5674,16 @@ static struct pipe *parse_stream(char **pstring,
5677 syntax_error("\\<eof>"); 5674 syntax_error("\\<eof>");
5678 xfunc_die(); 5675 xfunc_die();
5679 } 5676 }
5680 o_addchr(&dest, '\\');
5681 ch = i_getch(input); 5677 ch = i_getch(input);
5682 nommu_addchr(&ctx.as_string, ch); 5678 if (ch != '\n') {
5683 o_addchr(&dest, ch); 5679 o_addchr(&dest, '\\');
5684 /* Example: echo Hello \2>file 5680 nommu_addchr(&ctx.as_string, '\\');
5685 * we need to know that word 2 is quoted */ 5681 o_addchr(&dest, ch);
5686 dest.o_quoted = 1; 5682 nommu_addchr(&ctx.as_string, ch);
5683 /* Example: echo Hello \2>file
5684 * we need to know that word 2 is quoted */
5685 dest.o_quoted = 1;
5686 }
5687 break; 5687 break;
5688 case '$': 5688 case '$':
5689 if (handle_dollar(&ctx.as_string, &dest, input) != 0) { 5689 if (handle_dollar(&ctx.as_string, &dest, input) != 0) {
diff --git a/shell/hush_test/hush-parsing/escape4.right b/shell/hush_test/hush-parsing/escape4.right
new file mode 100644
index 000000000..5de3e0c90
--- /dev/null
+++ b/shell/hush_test/hush-parsing/escape4.right
@@ -0,0 +1,2 @@
1Ok
2End
diff --git a/shell/hush_test/hush-parsing/escape4.tests b/shell/hush_test/hush-parsing/escape4.tests
new file mode 100755
index 000000000..df8bf0af7
--- /dev/null
+++ b/shell/hush_test/hush-parsing/escape4.tests
@@ -0,0 +1,6 @@
1i\
2f tr\
3ue; th\
4en echo "O\
5k"; fi; echo "\
6End" \ No newline at end of file
diff --git a/shell/hush_test/hush-parsing/group1.tests b/shell/hush_test/hush-parsing/group1.tests
index f063fbcb3..f063fbcb3 100644..100755
--- a/shell/hush_test/hush-parsing/group1.tests
+++ b/shell/hush_test/hush-parsing/group1.tests