From 63c42afaa43d42def05dfbca1f4e10c7314b1f77 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 24 Jul 2018 17:08:04 +0200 Subject: hush: add "heredoc.tests" from ash, tweak ash "is a function" message Signed-off-by: Denys Vlasenko --- shell/ash.c | 3 +- shell/ash_test/ash-heredoc/heredoc.right | 2 +- shell/hush_test/hush-heredoc/heredoc.right | 20 ++++++ shell/hush_test/hush-heredoc/heredoc.tests | 97 ++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 shell/hush_test/hush-heredoc/heredoc.right create mode 100755 shell/hush_test/hush-heredoc/heredoc.tests (limited to 'shell') 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) case CMDFUNCTION: if (describe_command_verbose) { - out1str(" is a shell function"); + /*out1str(" is a shell function");*/ + out1str(" is a function"); /* bash says this */ } else { out1str(command); } 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 abc def ghi jkl mno -fff is a shell function +fff is a function hi there 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 @@ +there +one - alpha +two - beta +three - gamma +hi\ +there$a +stuff +hi\ +there +EO\ +F +hi +hi +tab 1 +tab 2 +tab 3 +abc +def ghi +jkl mno +fff 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 @@ +# check order and content of multiple here docs + +cat << EOF1 << EOF2 +hi +EOF1 +there +EOF2 + +while read line1; do + read line2 <&3 + echo $line1 - $line2 +done < /tmp/bash-zzz << EOF +abc +EOF +cat >> /tmp/bash-zzz << EOF +def ghi +jkl mno +EOF +cat /tmp/bash-zzz +rm -f /tmp/bash-zzz + +# make sure command printing puts the here-document as the last redirection +# on the line, and the function export code preserves syntactic correctness +fff() +{ + ed /tmp/foo </dev/null +/^name/d +w +q +ENDOFINPUT +aa=1 +} + +type fff +#ash# export -f fff +#ash# ${THIS_SH} -c 'type fff' + +#hush# bash warns: "here-document at line N delimited by end-of-file", +#hush# ash allows it, +#hush# hush errors out for now: +#hush# # check that end of file delimits a here-document +#hush# # THIS MUST BE LAST! +#hush# +#hush# cat << EOF +#hush# hi +#hush# there -- cgit v1.2.3