aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-25 19:01:49 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-25 19:01:49 +0100
commit1237d627e9fd996cc3d96ba72629371739fef776 (patch)
treea287c1c117d5490be91fcd31f8e9643e5f2b1859 /shell/hush.c
parent46a71dc30c62dde71d4e6714790b40187d378e82 (diff)
downloadbusybox-1237d627e9fd996cc3d96ba72629371739fef776.tar.gz
hush: fix this case: echo "SCRIPT" | hush
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 3bdbe26d8..f9a295e8d 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,