mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 03:21:16 -03:00
function: Check if --argument-names gets a valid variable name
These were accepted but then ineffective because the only way these are used is to set a variable.
This commit is contained in:
@@ -320,6 +320,15 @@ pub fn function(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
for named in &opts.named_arguments {
|
||||||
|
if !valid_var_name(&named) {
|
||||||
|
streams
|
||||||
|
.err
|
||||||
|
.append(wgettext_fmt!(BUILTIN_ERR_VARNAME, cmd, named));
|
||||||
|
return STATUS_INVALID_ARGS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We have what we need to actually define the function.
|
// We have what we need to actually define the function.
|
||||||
let props = function::FunctionProperties {
|
let props = function::FunctionProperties {
|
||||||
func_node,
|
func_node,
|
||||||
|
|||||||
@@ -167,4 +167,10 @@ function foo -p bar; end
|
|||||||
# CHECKERR: function foo -p bar; end
|
# CHECKERR: function foo -p bar; end
|
||||||
# CHECKERR: ^~~~~~~~~~~~~~~~~~~^
|
# CHECKERR: ^~~~~~~~~~~~~~~~~~~^
|
||||||
|
|
||||||
|
function foo --argument-names "banana pajama"; end
|
||||||
|
# CHECKERR: {{.*}}function.fish (line {{\d+}}): function: banana pajama: invalid variable name. See `help identifiers`
|
||||||
|
# CHECKERR: function foo --argument-names "banana pajama"; end
|
||||||
|
# CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user