From 66938d206a0a801ecee87e21863badef7d0d5587 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 22 Oct 2019 21:56:44 +0200 Subject: [PATCH] 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`. --- src/builtin_string.cpp | 6 ++++++ tests/checks/string.fish | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index b3d1663ef..637492da3 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -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 matcher; if (opts.regex) { matcher = make_unique(cmd, pattern, opts, streams); diff --git a/tests/checks/string.fish b/tests/checks/string.fish index f1e598434..a82b15883 100644 --- a/tests/checks/string.fish +++ b/tests/checks/string.fish @@ -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