diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-12 19:47:44 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-12 19:47:44 +0200 |
commit | cbfe6ad4c6c6a218a3dd89623911183aca91b061 (patch) | |
tree | 10e0cbe1c2c7b87e828784c64628a84e2cfa795a /shell | |
parent | 19679784c03089c585c609335389f034172a11ff (diff) | |
download | busybox-w32-cbfe6ad4c6c6a218a3dd89623911183aca91b061.tar.gz busybox-w32-cbfe6ad4c6c6a218a3dd89623911183aca91b061.tar.bz2 busybox-w32-cbfe6ad4c6c6a218a3dd89623911183aca91b061.zip |
hush: fix \<newline> handling on NOMMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/hush.c | 9 | ||||
-rw-r--r-- | shell/hush_test/hush-misc/nommu1.right | 7 | ||||
-rwxr-xr-x | shell/hush_test/hush-misc/nommu1.tests | 12 | ||||
-rwxr-xr-x | shell/hush_test/run-all | 20 |
4 files changed, 37 insertions, 11 deletions
diff --git a/shell/hush.c b/shell/hush.c index f49630a75..08e7f5052 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -6038,6 +6038,8 @@ static struct pipe *parse_stream(char **pstring, | |||
6038 | dest.o_assignment = NOT_ASSIGNMENT; | 6038 | dest.o_assignment = NOT_ASSIGNMENT; |
6039 | } | 6039 | } |
6040 | 6040 | ||
6041 | /* Note: nommu_addchr(&ctx.as_string, ch) is already done */ | ||
6042 | |||
6041 | switch (ch) { | 6043 | switch (ch) { |
6042 | case '#': | 6044 | case '#': |
6043 | if (dest.length == 0) { | 6045 | if (dest.length == 0) { |
@@ -6061,12 +6063,17 @@ static struct pipe *parse_stream(char **pstring, | |||
6061 | ch = i_getch(input); | 6063 | ch = i_getch(input); |
6062 | if (ch != '\n') { | 6064 | if (ch != '\n') { |
6063 | o_addchr(&dest, '\\'); | 6065 | o_addchr(&dest, '\\'); |
6064 | nommu_addchr(&ctx.as_string, '\\'); | 6066 | /*nommu_addchr(&ctx.as_string, '\\'); - already done */ |
6065 | o_addchr(&dest, ch); | 6067 | o_addchr(&dest, ch); |
6066 | nommu_addchr(&ctx.as_string, ch); | 6068 | nommu_addchr(&ctx.as_string, ch); |
6067 | /* Example: echo Hello \2>file | 6069 | /* Example: echo Hello \2>file |
6068 | * we need to know that word 2 is quoted */ | 6070 | * we need to know that word 2 is quoted */ |
6069 | dest.o_quoted = 1; | 6071 | dest.o_quoted = 1; |
6072 | } else { | ||
6073 | #if !BB_MMU | ||
6074 | /* It's "\<newline>". Remove trailing '\' from ctx.as_string */ | ||
6075 | ctx.as_string.data[--ctx.as_string.length] = '\0'; | ||
6076 | #endif | ||
6070 | } | 6077 | } |
6071 | break; | 6078 | break; |
6072 | case '$': | 6079 | case '$': |
diff --git a/shell/hush_test/hush-misc/nommu1.right b/shell/hush_test/hush-misc/nommu1.right new file mode 100644 index 000000000..d206a854b --- /dev/null +++ b/shell/hush_test/hush-misc/nommu1.right | |||
@@ -0,0 +1,7 @@ | |||
1 | Ok | ||
2 | Ok | ||
3 | Ok | ||
4 | Ok | ||
5 | Ok | ||
6 | Ok | ||
7 | Done | ||
diff --git a/shell/hush_test/hush-misc/nommu1.tests b/shell/hush_test/hush-misc/nommu1.tests new file mode 100755 index 000000000..e14ada5f9 --- /dev/null +++ b/shell/hush_test/hush-misc/nommu1.tests | |||
@@ -0,0 +1,12 @@ | |||
1 | (echo \ | ||
2 | Ok) | ||
3 | ( (echo \ | ||
4 | Ok) ) | ||
5 | ( ( (echo \ | ||
6 | Ok) ) ) | ||
7 | |||
8 | (echo \Ok) | ||
9 | ( (echo \Ok) ) | ||
10 | ( ( (echo \Ok) ) ) | ||
11 | |||
12 | echo Done | ||
diff --git a/shell/hush_test/run-all b/shell/hush_test/run-all index cde841e66..ee8327f0d 100755 --- a/shell/hush_test/run-all +++ b/shell/hush_test/run-all | |||
@@ -38,16 +38,16 @@ do_test() | |||
38 | tret=0 | 38 | tret=0 |
39 | cd "$1" || { echo "cannot cd $1!"; exit 1; } | 39 | cd "$1" || { echo "cannot cd $1!"; exit 1; } |
40 | for x in run-*; do | 40 | for x in run-*; do |
41 | test -f "$x" || continue | 41 | test -f "$x" || continue |
42 | case "$x" in | 42 | case "$x" in |
43 | "$0"|run-minimal|run-gprof) ;; | 43 | "$0"|run-minimal|run-gprof) ;; |
44 | *.orig|*~) ;; | 44 | *.orig|*~) ;; |
45 | #*) echo $x ; sh $x ;; | 45 | #*) echo $x ; sh $x ;; |
46 | *) | 46 | *) |
47 | sh "$x" >"../$1-$x.fail" 2>&1 && \ | 47 | sh "$x" >"../$1-$x.fail" 2>&1 && \ |
48 | { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail"; | 48 | { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail"; |
49 | ;; | 49 | ;; |
50 | esac | 50 | esac |
51 | done | 51 | done |
52 | # Many bash run-XXX scripts just do this, | 52 | # Many bash run-XXX scripts just do this, |
53 | # no point in duplication it all over the place | 53 | # no point in duplication it all over the place |