Builtin source to print error if missing both file argument and piped stdin
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run

Closes #10774
This commit is contained in:
Johannes Altmanninger 2024-10-13 10:31:32 +02:00
parent 00875d0f83
commit 2dafe81f97

View File

@ -45,6 +45,10 @@ pub fn source(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O
// Either a bare `source` which means to implicitly read from stdin or an explicit `-`.
if argc == optind && isatty(streams.stdin_fd) {
// Don't implicitly read from the terminal.
streams.err.append(wgettext_fmt!(
"%ls: missing filename argument or input redirection\n",
cmd
));
return STATUS_CMD_ERROR;
}
func_filename = FilenameRef::new(L!("-").to_owned());