mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08: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
|
@ -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 New Issue
Block a user