diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-03-05 21:08:29 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-03-05 21:08:29 +0000 |
commit | 12a403bcb5e2a400300ae856b6fcdb0f1fc324f5 (patch) | |
tree | c6d7b1e3f643ba23d4dfa1d9adeb5e72688dff0d | |
parent | 9130eb616546c6265cf2207a207e5c18fe7d8c7f (diff) | |
download | busybox-w32-12a403bcb5e2a400300ae856b6fcdb0f1fc324f5.tar.gz busybox-w32-12a403bcb5e2a400300ae856b6fcdb0f1fc324f5.tar.bz2 busybox-w32-12a403bcb5e2a400300ae856b6fcdb0f1fc324f5.zip |
ash: "here document" testcases
git-svn-id: svn://busybox.net/trunk/busybox@18014 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | shell/ash_test/ash-heredoc/heredoc.right | 21 | ||||
-rwxr-xr-x | shell/ash_test/ash-heredoc/heredoc.tests | 94 |
2 files changed, 115 insertions, 0 deletions
diff --git a/shell/ash_test/ash-heredoc/heredoc.right b/shell/ash_test/ash-heredoc/heredoc.right new file mode 100644 index 000000000..baf115166 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc.right | |||
@@ -0,0 +1,21 @@ | |||
1 | there | ||
2 | one - alpha | ||
3 | two - beta | ||
4 | three - gamma | ||
5 | hi\ | ||
6 | there$a | ||
7 | stuff | ||
8 | hi\ | ||
9 | there | ||
10 | EO\ | ||
11 | F | ||
12 | hi | ||
13 | tab 1 | ||
14 | tab 2 | ||
15 | tab 3 | ||
16 | abc | ||
17 | def ghi | ||
18 | jkl mno | ||
19 | fff is a shell function | ||
20 | hi | ||
21 | there | ||
diff --git a/shell/ash_test/ash-heredoc/heredoc.tests b/shell/ash_test/ash-heredoc/heredoc.tests new file mode 100755 index 000000000..31316a58d --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc.tests | |||
@@ -0,0 +1,94 @@ | |||
1 | # check order and content of multiple here docs | ||
2 | |||
3 | cat << EOF1 << EOF2 | ||
4 | hi | ||
5 | EOF1 | ||
6 | there | ||
7 | EOF2 | ||
8 | |||
9 | while read line1; do | ||
10 | read line2 <&3 | ||
11 | echo $line1 - $line2 | ||
12 | done <<EOF1 3<<EOF2 | ||
13 | one | ||
14 | two | ||
15 | three | ||
16 | EOF1 | ||
17 | alpha | ||
18 | beta | ||
19 | gamma | ||
20 | EOF2 | ||
21 | |||
22 | |||
23 | # check quoted here-doc is protected | ||
24 | |||
25 | a=foo | ||
26 | cat << 'EOF' | ||
27 | hi\ | ||
28 | there$a | ||
29 | stuff | ||
30 | EOF | ||
31 | |||
32 | # check that quoted here-documents don't have \newline processing done | ||
33 | |||
34 | cat << 'EOF' | ||
35 | hi\ | ||
36 | there | ||
37 | EO\ | ||
38 | F | ||
39 | EOF | ||
40 | true | ||
41 | |||
42 | # check that \newline is removed at start of here-doc | ||
43 | cat << EO\ | ||
44 | F | ||
45 | hi | ||
46 | EOF | ||
47 | |||
48 | #ash# # check that \newline removal works for here-doc delimiter | ||
49 | #ash# cat << EOF | ||
50 | #ash# hi | ||
51 | #ash# EO\ | ||
52 | #ash# F | ||
53 | |||
54 | # check operation of tab removal in here documents | ||
55 | cat <<- EOF | ||
56 | tab 1 | ||
57 | tab 2 | ||
58 | tab 3 | ||
59 | EOF | ||
60 | |||
61 | # check appending of text to file from here document | ||
62 | rm -f /tmp/bash-zzz | ||
63 | cat > /tmp/bash-zzz << EOF | ||
64 | abc | ||
65 | EOF | ||
66 | cat >> /tmp/bash-zzz << EOF | ||
67 | def ghi | ||
68 | jkl mno | ||
69 | EOF | ||
70 | cat /tmp/bash-zzz | ||
71 | rm -f /tmp/bash-zzz | ||
72 | |||
73 | # make sure command printing puts the here-document as the last redirection | ||
74 | # on the line, and the function export code preserves syntactic correctness | ||
75 | fff() | ||
76 | { | ||
77 | ed /tmp/foo <<ENDOFINPUT >/dev/null | ||
78 | /^name/d | ||
79 | w | ||
80 | q | ||
81 | ENDOFINPUT | ||
82 | aa=1 | ||
83 | } | ||
84 | |||
85 | type fff | ||
86 | #ash# export -f fff | ||
87 | #ash# ${THIS_SH} -c 'type fff' | ||
88 | |||
89 | # check that end of file delimits a here-document | ||
90 | # THIS MUST BE LAST! | ||
91 | |||
92 | cat << EOF | ||
93 | hi | ||
94 | there | ||