aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash_test/ash-heredoc/heredoc_empty3.right2
-rwxr-xr-xshell/ash_test/ash-heredoc/heredoc_empty3.tests4
-rw-r--r--shell/hush.c8
-rw-r--r--shell/hush_test/hush-heredoc/heredoc_empty3.right2
-rwxr-xr-xshell/hush_test/hush-heredoc/heredoc_empty3.tests4
5 files changed, 20 insertions, 0 deletions
diff --git a/shell/ash_test/ash-heredoc/heredoc_empty3.right b/shell/ash_test/ash-heredoc/heredoc_empty3.right
new file mode 100644
index 000000000..0b54a9c93
--- /dev/null
+++ b/shell/ash_test/ash-heredoc/heredoc_empty3.right
@@ -0,0 +1,2 @@
1
2Ok
diff --git a/shell/ash_test/ash-heredoc/heredoc_empty3.tests b/shell/ash_test/ash-heredoc/heredoc_empty3.tests
new file mode 100755
index 000000000..828c2dd89
--- /dev/null
+++ b/shell/ash_test/ash-heredoc/heredoc_empty3.tests
@@ -0,0 +1,4 @@
1cat <<EOF
2
3Ok
4EOF
diff --git a/shell/hush.c b/shell/hush.c
index 4fdd15900..89e06df4d 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4226,6 +4226,14 @@ static char *fetch_till_str(o_string *as_string,
4226 int prev = 0; /* not \ */ 4226 int prev = 0; /* not \ */
4227 int ch; 4227 int ch;
4228 4228
4229 /* Starting with "" is necessary for this case:
4230 * cat <<EOF
4231 *
4232 * xxx
4233 * EOF
4234 */
4235 heredoc.data = xzalloc(1); /* start as "", not as NULL */
4236
4229 goto jump_in; 4237 goto jump_in;
4230 4238
4231 while (1) { 4239 while (1) {
diff --git a/shell/hush_test/hush-heredoc/heredoc_empty3.right b/shell/hush_test/hush-heredoc/heredoc_empty3.right
new file mode 100644
index 000000000..0b54a9c93
--- /dev/null
+++ b/shell/hush_test/hush-heredoc/heredoc_empty3.right
@@ -0,0 +1,2 @@
1
2Ok
diff --git a/shell/hush_test/hush-heredoc/heredoc_empty3.tests b/shell/hush_test/hush-heredoc/heredoc_empty3.tests
new file mode 100755
index 000000000..828c2dd89
--- /dev/null
+++ b/shell/hush_test/hush-heredoc/heredoc_empty3.tests
@@ -0,0 +1,4 @@
1cat <<EOF
2
3Ok
4EOF