mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
set: Add special error for set foo=bar
Fixes #8694 Only for setting, erasing with a value makes no sense.
This commit is contained in:
parent
31e2476fc8
commit
b0c2d083d6
2 changed files with 13 additions and 0 deletions
|
@ -720,6 +720,12 @@ static int builtin_set_set(const wchar_t *cmd, set_cmd_opts_t &opts, int argc, c
|
|||
// Is the variable valid?
|
||||
if (!valid_var_name(split->varname)) {
|
||||
streams.err.append_format(BUILTIN_ERR_VARNAME, cmd, split->varname.c_str());
|
||||
auto pos = split->varname.find(L'=');
|
||||
if (pos != wcstring::npos) {
|
||||
streams.err.append_format(L"%ls: Did you mean `set %ls %ls`?", cmd,
|
||||
escape_string(split->varname.substr(0, pos), ESCAPE_ALL, STRING_STYLE_SCRIPT).c_str(),
|
||||
escape_string(split->varname.substr(pos + 1), ESCAPE_ALL, STRING_STYLE_SCRIPT).c_str());
|
||||
}
|
||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
|
|
@ -770,6 +770,13 @@ set --show ""
|
|||
#CHECKERR: ^
|
||||
#CHECKERR: (Type 'help set' for related documentation)
|
||||
|
||||
set foo="ba nana"
|
||||
#CHECKERR: set: foo=ba nana: invalid variable name. See `help identifiers`
|
||||
#CHECKERR: set: Did you mean `set foo 'ba nana'`?
|
||||
#CHECKERR: {{.*}}set.fish (line {{\d+}}):
|
||||
#CHECKERR: set foo="ba nana"
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: (Type 'help set' for related documentation)
|
||||
# Test path splitting
|
||||
begin
|
||||
set -l PATH /usr/local/bin:/usr/bin
|
||||
|
|
Loading…
Reference in a new issue