fish_indent: handle invalid arguments

This commit is contained in:
Johannes Altmanninger
2025-12-09 11:40:37 +01:00
parent 692e6d57cf
commit 07389055f1
2 changed files with 20 additions and 1 deletions

View File

@@ -974,7 +974,23 @@ enum OutputType {
'\x02' => output_type = OutputType::Ansi,
'\x03' => output_type = OutputType::PygmentsCsv,
'c' => output_type = OutputType::Check,
_ => return Err(STATUS_CMD_ERROR),
';' => {
streams.err.append(wgettext_fmt!(
BUILTIN_ERR_UNEXP_ARG,
"fish_indent",
w.argv[w.wopt_index - 1]
));
return Err(STATUS_CMD_ERROR);
}
'?' => {
streams.err.append(wgettext_fmt!(
BUILTIN_ERR_UNKNOWN,
"fish_indent",
w.argv[w.wopt_index - 1]
));
return Err(STATUS_CMD_ERROR);
}
_ => panic!(),
}
}

View File

@@ -2,6 +2,9 @@
# Test file for fish_indent
# Note that littlecheck ignores leading whitespace, so we have to use {{ }} to explicitly match it.
fish_indent --no-such-option
#CHECKERR: fish_indent: --no-such-option: unknown option
echo 'echo foo \\
| cat' | $fish_indent
#CHECK: echo foo \