string: Error out on match -eq

The `--entire` would enable output even though the `--quiet` should
have silenced it. These two don't make any sense together so print an
error, because the user could have just left off the `-q`.
This commit is contained in:
Fabian Homborg 2019-10-22 21:56:44 +02:00
parent d579964c7d
commit 66938d206a
2 changed files with 10 additions and 0 deletions

View file

@ -864,6 +864,12 @@ static int string_match(parser_t &parser, io_streams_t &streams, int argc, wchar
return STATUS_INVALID_ARGS;
}
if (opts.entire && opts.quiet) {
streams.err.append_format(BUILTIN_ERR_COMBO2, cmd,
_(L"--entire and --quiet are mutually exclusive"));
return STATUS_INVALID_ARGS;
}
std::unique_ptr<string_matcher_t> matcher;
if (opts.regex) {
matcher = make_unique<pcre2_matcher_t>(cmd, pattern, opts, streams);

View file

@ -559,3 +559,7 @@ function dualcollect
end
count (dualcollect)
# CHECK: 3
string match -qer asd asd
# CHECKERR: match: Invalid combination of options,
# CHECKERR: --entire and --quiet are mutually exclusive