From 17cf255bf7f765c9510f88a6fcebca701519d20d Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Fri, 28 Jul 2017 14:11:14 -0700 Subject: [PATCH] warn when people try to do `set -ex var` A person asked in issue #4263 why `set -ex fish_greeting` didn't work. So issue an error to let people know that combination doesn't make sense. --- src/builtin_set.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index 51e103b11..fca3bfff4 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -170,6 +170,13 @@ static int validate_cmd_opts(const wchar_t *cmd, set_cmd_opts_t &opts, int argc, return STATUS_INVALID_ARGS; } + // Trying to erase and (un)export at the same time doesn't make sense. + if (opts.erase && (opts.exportv || opts.unexport)) { + streams.err.append_format(BUILTIN_ERR_COMBO, cmd); + builtin_print_help(parser, streams, cmd, streams.err); + return STATUS_INVALID_ARGS; + } + if (argc == 0 && opts.erase) { streams.err.append_format(BUILTIN_SET_ERASE_NO_VAR, cmd); builtin_print_help(parser, streams, cmd, streams.err);