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.
This commit is contained in:
Kurtis Rader 2017-07-28 14:11:14 -07:00
parent f2724da45c
commit 17cf255bf7

View file

@ -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);