mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-29 10:31:14 -03:00
function: Error out for read-only variables
This will refuse to define the function instead of defining it with an unusable argument. Fixes #10842
This commit is contained in:
@@ -162,6 +162,8 @@ end
|
||||
|
||||
rm -r $tmpdir
|
||||
|
||||
functions -e foo
|
||||
|
||||
function foo -p bar; end
|
||||
# CHECKERR: {{.*}}function.fish (line {{\d+}}): function: bar: invalid process id
|
||||
# CHECKERR: function foo -p bar; end
|
||||
@@ -173,4 +175,16 @@ function foo --argument-names "banana pajama"; end
|
||||
# CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
|
||||
|
||||
|
||||
function foo --argument-names status; end
|
||||
# CHECKERR: {{.*}}function.fish (line {{\d+}}): function: variable 'status' is read-only
|
||||
# CHECKERR: function foo --argument-names status; end
|
||||
# CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
|
||||
|
||||
echo status $status
|
||||
# CHECK: status 2
|
||||
|
||||
functions -q foo
|
||||
echo exists $status
|
||||
# CHECK: exists 1
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user