mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 15:01:16 -03:00
function: Also error for read-only var in positional arg
We have this hack where any positional arguments are taken as argument
names if "--argument-names" is given, and that didn't check for
read-only variables.
Fixes #11295
(cherry picked from commit d203ee4d53)
This commit is contained in:
@@ -92,6 +92,14 @@ fn parse_cmd_opts(
|
||||
// A positional argument we got because we use RETURN_IN_ORDER.
|
||||
let woptarg = w.woptarg.unwrap().to_owned();
|
||||
if handling_named_arguments {
|
||||
if is_read_only(&woptarg) {
|
||||
streams.err.append(wgettext_fmt!(
|
||||
"%ls: variable '%ls' is read-only\n",
|
||||
cmd,
|
||||
woptarg
|
||||
));
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
opts.named_arguments.push(woptarg);
|
||||
} else {
|
||||
streams.err.append(wgettext_fmt!(
|
||||
|
||||
Reference in New Issue
Block a user