aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-07-24 17:08:04 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-07-24 17:10:18 +0200
commit63c42afaa43d42def05dfbca1f4e10c7314b1f77 (patch)
treeb88436d25560b74b7f626739c4ab14c12aff219a
parent41ef41b3e0a16c9f8524870a2dc4f768c237939e (diff)
downloadbusybox-w32-63c42afaa43d42def05dfbca1f4e10c7314b1f77.tar.gz
busybox-w32-63c42afaa43d42def05dfbca1f4e10c7314b1f77.tar.bz2
busybox-w32-63c42afaa43d42def05dfbca1f4e10c7314b1f77.zip
hush: add "heredoc.tests" from ash, tweak ash "is a function" message
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c3
-rw-r--r--shell/ash_test/ash-heredoc/heredoc.right2
-rw-r--r--shell/hush_test/hush-heredoc/heredoc.right20
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc.tests97
4 files changed, 120 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 051cc671f..03fbbee53 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8512,7 +8512,8 @@ describe_command(char *command, const char *path, int describe_command_verbose)
8512 8512
8513 case CMDFUNCTION: 8513 case CMDFUNCTION:
8514 if (describe_command_verbose) { 8514 if (describe_command_verbose) {
8515 out1str(" is a shell function"); 8515 /*out1str(" is a shell function");*/
8516 out1str(" is a function"); /* bash says this */
8516 } else { 8517 } else {
8517 out1str(command); 8518 out1str(command);
8518 } 8519 }
diff --git a/shell/ash_test/ash-heredoc/heredoc.right b/shell/ash_test/ash-heredoc/heredoc.right
index baf115166..85d36dae9 100644
--- a/shell/ash_test/ash-heredoc/heredoc.right
+++ b/shell/ash_test/ash-heredoc/heredoc.right
@@ -16,6 +16,6 @@ tab 3
16abc 16abc
17def ghi 17def ghi
18jkl mno 18jkl mno
19fff is a shell function 19fff is a function
20hi 20hi
21there 21there
diff --git a/shell/hush_test/hush-heredoc/heredoc.right b/shell/hush_test/hush-heredoc/heredoc.right
new file mode 100644
index 000000000..9b9e2aae9
--- /dev/null
+++ b/shell/hush_test/hush-heredoc/heredoc.right
@@ -0,0 +1,20 @@
1there
2one - alpha
3two - beta
4three - gamma
5hi\
6there$a
7stuff
8hi\
9there
10EO\
11F
12hi
13hi
14tab 1
15tab 2
16tab 3
17abc
18def ghi
19jkl mno
20fff is a function
diff --git a/shell/hush_test/hush-heredoc/heredoc.tests b/shell/hush_test/hush-heredoc/heredoc.tests
new file mode 100755
index 000000000..39345c51b
--- /dev/null
+++ b/shell/hush_test/hush-heredoc/heredoc.tests
@@ -0,0 +1,97 @@
1# check order and content of multiple here docs
2
3cat << EOF1 << EOF2
4hi
5EOF1
6there
7EOF2
8
9while read line1; do
10 read line2 <&3
11 echo $line1 - $line2
12done <<EOF1 3<<EOF2
13one
14two
15three
16EOF1
17alpha
18beta
19gamma
20EOF2
21
22
23# check quoted here-doc is protected
24
25a=foo
26cat << 'EOF'
27hi\
28there$a
29stuff
30EOF
31
32# check that quoted here-documents don't have \newline processing done
33
34cat << 'EOF'
35hi\
36there
37EO\
38F
39EOF
40true
41
42# check that \newline is removed at start of here-doc
43cat << EO\
44F
45hi
46EOF
47
48# check that \newline removal works for here-doc delimiter
49cat << EOF
50hi
51EO\
52F
53
54# check operation of tab removal in here documents
55cat <<- EOF
56 tab 1
57 tab 2
58 tab 3
59 EOF
60
61# check appending of text to file from here document
62rm -f /tmp/bash-zzz
63cat > /tmp/bash-zzz << EOF
64abc
65EOF
66cat >> /tmp/bash-zzz << EOF
67def ghi
68jkl mno
69EOF
70cat /tmp/bash-zzz
71rm -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
75fff()
76{
77 ed /tmp/foo <<ENDOFINPUT >/dev/null
78/^name/d
79w
80q
81ENDOFINPUT
82aa=1
83}
84
85type fff
86#ash# export -f fff
87#ash# ${THIS_SH} -c 'type fff'
88
89#hush# bash warns: "here-document at line N delimited by end-of-file",
90#hush# ash allows it,
91#hush# hush errors out for now:
92#hush# # check that end of file delimits a here-document
93#hush# # THIS MUST BE LAST!
94#hush#
95#hush# cat << EOF
96#hush# hi
97#hush# there