summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ash_test/ash-misc/piped_input.right2
-rwxr-xr-xshell/ash_test/ash-misc/piped_input.tests3
-rw-r--r--shell/hush.c6
-rw-r--r--shell/hush_test/hush-misc/piped_input.right2
-rwxr-xr-xshell/hush_test/hush-misc/piped_input.tests3
5 files changed, 15 insertions, 1 deletions
diff --git a/shell/ash_test/ash-misc/piped_input.right b/shell/ash_test/ash-misc/piped_input.right
new file mode 100644
index 0000000..7b8bf67
--- /dev/null
+++ b/shell/ash_test/ash-misc/piped_input.right
@@ -0,0 +1,2 @@
+TEST
+One:1
diff --git a/shell/ash_test/ash-misc/piped_input.tests b/shell/ash_test/ash-misc/piped_input.tests
new file mode 100755
index 0000000..ec7e498
--- /dev/null
+++ b/shell/ash_test/ash-misc/piped_input.tests
@@ -0,0 +1,3 @@
+exed 2>&1
+echo 'echo TEST; false' | $THIS_SH
+echo One:$?
diff --git a/shell/hush.c b/shell/hush.c
index 3bdbe26..f9a295e 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7787,7 +7787,11 @@ static void restore_redirects(struct squirrel *sq)
free(sq);
}
if (G.HFILE_stdin
- && G.HFILE_stdin->fd != STDIN_FILENO
+ && G.HFILE_stdin->fd > STDIN_FILENO
+ /* we compare > STDIN, not == STDIN, since hfgetc()
+ * closes fd and sets ->fd to -1 if EOF is reached.
+ * Testcase: echo 'pwd' | hush
+ */
) {
/* Testcase: interactive "read r <FILE; echo $r; read r; echo $r".
* Redirect moves ->fd to e.g. 10,
diff --git a/shell/hush_test/hush-misc/piped_input.right b/shell/hush_test/hush-misc/piped_input.right
new file mode 100644
index 0000000..7b8bf67
--- /dev/null
+++ b/shell/hush_test/hush-misc/piped_input.right
@@ -0,0 +1,2 @@
+TEST
+One:1
diff --git a/shell/hush_test/hush-misc/piped_input.tests b/shell/hush_test/hush-misc/piped_input.tests
new file mode 100755
index 0000000..ec7e498
--- /dev/null
+++ b/shell/hush_test/hush-misc/piped_input.tests
@@ -0,0 +1,3 @@
+exed 2>&1
+echo 'echo TEST; false' | $THIS_SH
+echo One:$?