summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2009-05-03 02:15:18 +0200
committerDenys Vlasenko2009-05-03 02:15:18 +0200
commite19e1935a33b117e2ee6daf9b2d79c00603333c7 (patch)
tree8154fc2bfedd1fccb7ed1c0b7b2fff2e57f36e4e
parentb1cfc453760b3b3b81bb3217f68074a98c96084b (diff)
downloadbusybox-e19e1935a33b117e2ee6daf9b2d79c00603333c7.zip
busybox-e19e1935a33b117e2ee6daf9b2d79c00603333c7.tar.gz
hush: fix \<newline> handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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 255caef..c6e9405 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -50,14 +50,9 @@
*
* TODOs:
* grep for "TODO" and fix (some of them are easy)
- * change { and } from special chars to reserved words
* $var refs in function do not pick up values set by "var=val func"
* builtins: ulimit
* follow IFS rules more precisely, including update semantics
- * figure out what to do with backslash-newline
- * continuation lines, both explicit and implicit - done?
- * separate job control from interactiveness
- * (testcase: booting with init=/bin/hush does not show prompt (2009-04))
*
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
@@ -5347,10 +5342,12 @@ static int parse_stream_dquoted(o_string *as_string,
* $, `, ", \, or <newline>. A double quote may be quoted
* within double quotes by preceding it with a backslash.
*/
- if (strchr("$`\"\\", next) != NULL) {
+ if (strchr("$`\"\\\n", next) != NULL) {
ch = i_getch(input);
- o_addqchr(dest, ch);
- nommu_addchr(as_string, ch);
+ if (ch != '\n') {
+ o_addqchr(dest, ch);
+ nommu_addchr(as_string, ch);
+ }
} else {
o_addqchr(dest, '\\');
nommu_addchr(as_string, '\\');
@@ -5677,13 +5674,16 @@ static struct pipe *parse_stream(char **pstring,
syntax_error("\\<eof>");
xfunc_die();
}
- o_addchr(&dest, '\\');
ch = i_getch(input);
- nommu_addchr(&ctx.as_string, ch);
- o_addchr(&dest, ch);
- /* Example: echo Hello \2>file
- * we need to know that word 2 is quoted */
- dest.o_quoted = 1;
+ if (ch != '\n') {
+ o_addchr(&dest, '\\');
+ nommu_addchr(&ctx.as_string, '\\');
+ o_addchr(&dest, ch);
+ nommu_addchr(&ctx.as_string, ch);
+ /* Example: echo Hello \2>file
+ * we need to know that word 2 is quoted */
+ dest.o_quoted = 1;
+ }
break;
case '$':
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 0000000..5de3e0c
--- /dev/null
+++ b/shell/hush_test/hush-parsing/escape4.right
@@ -0,0 +1,2 @@
+Ok
+End
diff --git a/shell/hush_test/hush-parsing/escape4.tests b/shell/hush_test/hush-parsing/escape4.tests
new file mode 100755
index 0000000..df8bf0a
--- /dev/null
+++ b/shell/hush_test/hush-parsing/escape4.tests
@@ -0,0 +1,6 @@
+i\
+f tr\
+ue; th\
+en echo "O\
+k"; fi; echo "\
+End" \ 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 f063fbc..f063fbc 100644..100755
--- a/shell/hush_test/hush-parsing/group1.tests
+++ b/shell/hush_test/hush-parsing/group1.tests