aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-09-06 11:27:32 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-09-06 11:27:32 +0200
commit77b32ccbf2a1a77911b486b673008a4cb82bb8b7 (patch)
treec68a1bef8013018843321d6807aa87ca432808b1 /shell/hush_test
parentc49d2d97939d77be3d1f3bbbbf9db30a55771c15 (diff)
downloadbusybox-w32-77b32ccbf2a1a77911b486b673008a4cb82bb8b7.tar.gz
busybox-w32-77b32ccbf2a1a77911b486b673008a4cb82bb8b7.tar.bz2
busybox-w32-77b32ccbf2a1a77911b486b673008a4cb82bb8b7.zip
hush: fix backslash and terminator handling in <<[-]["]heredoc["]
function old new delta parse_stream 2339 2395 +56 expand_pseudo_dquoted 104 118 +14 parse_stream_dquoted 296 300 +4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 74/0) Total: 74 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'shell/hush_test')
-rw-r--r--shell/hush_test/hush-misc/heredoc_backslash1.right27
-rwxr-xr-xshell/hush_test/hush-misc/heredoc_backslash1.tests54
2 files changed, 81 insertions, 0 deletions
diff --git a/shell/hush_test/hush-misc/heredoc_backslash1.right b/shell/hush_test/hush-misc/heredoc_backslash1.right
new file mode 100644
index 000000000..234c0172f
--- /dev/null
+++ b/shell/hush_test/hush-misc/heredoc_backslash1.right
@@ -0,0 +1,27 @@
1Quoted heredoc:
2a\
3 b
4 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
5 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
6c\
7
8Unquoted heredoc:
9a b
10 123456 -qwerty-\t-\-\"-\'-`-\--\z-\*-\?-
11 -qwerty-\t-\-\"-\'-`-\--\z-\*-\?-
12cEOF2
13
14Quoted -heredoc:
15a\
16b
17 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
18-$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
19c\
20
21Unquoted -heredoc:
22a b
23 123456 -qwerty-\t-\-\"-\'-`-\--\z-\*-\?-
24-qwerty-\t-\-\"-\'-`-\--\z-\*-\?-
25cEOF4
26
27Done: 0
diff --git a/shell/hush_test/hush-misc/heredoc_backslash1.tests b/shell/hush_test/hush-misc/heredoc_backslash1.tests
new file mode 100755
index 000000000..b70467df8
--- /dev/null
+++ b/shell/hush_test/hush-misc/heredoc_backslash1.tests
@@ -0,0 +1,54 @@
1# Test for correct handling of backslashes.
2# Note that some lines in each heredoc start with a tab.
3
4a=qwerty
5
6echo Quoted heredoc:
7cat <<"EOF1"
8a\
9 b
10 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
11 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
12c\
13EOF1
14echo
15
16echo Unquoted heredoc:
17cat <<EOF2
18a\
19 b
20 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
21 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
22c\
23EOF2
24EOF2
25echo
26
27echo Quoted -heredoc:
28cat <<-"EOF3"
29a\
30 b
31 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
32 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
33c\
34 EOF3
35# In -heredoc case the marker is detected even if it is indented.
36echo
37
38echo Unquoted -heredoc:
39cat <<-EOF4
40a\
41 b
42 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
43 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
44c\
45EOF4
46 EOF4
47# The marker is not detected if preceding line ends in backslash.
48# TODO: marker should be detected even if it is split by line continuation:
49# EOF\
50# 4
51# but currently hush doesn't do it. (Tab before "4" is not allowed, though.)
52echo
53
54echo "Done: $?"