From 1237d627e9fd996cc3d96ba72629371739fef776 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 25 Dec 2020 19:01:49 +0100 Subject: hush: fix this case: echo "SCRIPT" | hush Signed-off-by: Denys Vlasenko --- shell/hush.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'shell/hush.c') 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 fd to e.g. 10, -- cgit v1.2.3