← Commit list

1237d627e

Denys Vlasenko
Denys Vlasenko
2020-12-25
SUCCESS Duration: 151s

Subject

hush: fix this case: echo "SCRIPT" | hush

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash_test/ash-misc/piped_input.right+2 -0
@@ -0,0 +1,2 @@
+TEST
+One:1
shell/ash_test/ash-misc/piped_input.tests+3 -0
@@ -0,0 +1,3 @@
+exed 2>&1
+echo 'echo TEST; false' | $THIS_SH
+echo One:$?
shell/hush.c+5 -1
@@ -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,
shell/hush_test/hush-misc/piped_input.right+2 -0
@@ -0,0 +1,2 @@
+TEST
+One:1
shell/hush_test/hush-misc/piped_input.tests+3 -0
@@ -0,0 +1,3 @@
+exed 2>&1
+echo 'echo TEST; false' | $THIS_SH
+echo One:$?