Builtin source to print error if missing both file argument and piped stdin

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 `-`. // Either a bare `source` which means to implicitly read from stdin or an explicit `-`.
if argc == optind && isatty(streams.stdin_fd) { if argc == optind && isatty(streams.stdin_fd) {
// Don't implicitly read from the terminal. // 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; return STATUS_CMD_ERROR;
} }
func_filename = FilenameRef::new(L!("-").to_owned()); func_filename = FilenameRef::new(L!("-").to_owned());