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.
This commit is contained in:
Fabian Homborg 2018-11-26 23:38:02 +01:00
parent 9e7034c903
commit a1c481c06a
2 changed files with 2 additions and 2 deletions

View File

@ -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;
}

View File

@ -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 </dev/tty
echo $status
always_fails