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