From a1c481c06aa187b741c5b4db22ae0629e949832d Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 26 Nov 2018 23:38:02 +0100 Subject: [PATCH] source: Actually check if stdin is a tty, not just redirected This broke fishtape, which did somestuff | fish -c "source" Because `source` didn't have a redirection, it refused to read from stdin. So, to keep the common issue of `source (command that does not print)` from seeminly stopping fish, we instead actually check if stdin is a terminal. --- src/builtin_source.cpp | 2 +- tests/test1.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builtin_source.cpp b/src/builtin_source.cpp index 655111e92..1e09b702e 100644 --- a/src/builtin_source.cpp +++ b/src/builtin_source.cpp @@ -41,7 +41,7 @@ int builtin_source(parser_t &parser, io_streams_t &streams, wchar_t **argv) { if (argc == optind || wcscmp(argv[optind], L"-") == 0) { // Either a bare `source` which means to implicitly read from stdin or an explicit `-`. - if (argc == optind && !streams.stdin_is_directly_redirected) { + if (argc == optind && isatty(streams.stdin_fd)) { // Don't implicitly read from the terminal. return STATUS_CMD_ERROR; } diff --git a/tests/test1.in b/tests/test1.in index e747f3143..104f984ea 100644 --- a/tests/test1.in +++ b/tests/test1.in @@ -214,7 +214,7 @@ echo 'echo "source argv {$argv}"' | source - echo 'echo "source argv {$argv}"' | source - abc echo 'echo "source argv {$argv}"' | source - abc def # This hangs if it fails! -source +source