mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Reserve some builtin names
`argparse`, `read`, `set`, `status`, `test` and `[` now can't be used as function names anymore. This is because (except for `test` and `[`) there is no way to wrap these properly, so any function called that will be broken anyway. For `test` (and `[`), there is nothing that can be added and there have been confused users who created a function that then broke everything. Fixes #3000.
This commit is contained in:
parent
5648322993
commit
69f68d31df
@ -40,6 +40,7 @@ This section is for changes merged to the `major` branch that are not also merge
|
|||||||
- The pager will now show the full command instead of just its last line if the number of completions is large (#4702).
|
- The pager will now show the full command instead of just its last line if the number of completions is large (#4702).
|
||||||
- Tildes in file names are now properly escaped in completions (#2274)
|
- Tildes in file names are now properly escaped in completions (#2274)
|
||||||
- A pipe at the end of a line now allows the job to continue on the next line (#1285)
|
- A pipe at the end of a line now allows the job to continue on the next line (#1285)
|
||||||
|
- The names `argparse`, `read`, `set`, `status`, `test` and `[` are now reserved and not allowed as function names. This prevents users unintentionally breaking stuff (#3000).
|
||||||
|
|
||||||
## Other significant changes
|
## Other significant changes
|
||||||
- Command substitution output is now limited to 10 MB by default (#3822).
|
- Command substitution output is now limited to 10 MB by default (#3822).
|
||||||
|
@ -22,7 +22,7 @@ static const wcstring_list_t block_keywords({L"for", L"while", L"if", L"function
|
|||||||
bool parser_keywords_is_block(const wcstring &word) { return contains(block_keywords, word); }
|
bool parser_keywords_is_block(const wcstring &word) { return contains(block_keywords, word); }
|
||||||
|
|
||||||
static const wcstring_list_t reserved_keywords({L"end", L"case", L"else", L"return", L"continue",
|
static const wcstring_list_t reserved_keywords({L"end", L"case", L"else", L"return", L"continue",
|
||||||
L"break"});
|
L"break", L"argparse", L"read", L"set", L"status", L"test", L"["});
|
||||||
bool parser_keywords_is_reserved(const wcstring &word) {
|
bool parser_keywords_is_reserved(const wcstring &word) {
|
||||||
return parser_keywords_is_block(word) || parser_keywords_is_subcommand(word) ||
|
return parser_keywords_is_block(word) || parser_keywords_is_subcommand(word) ||
|
||||||
contains(reserved_keywords, word);
|
contains(reserved_keywords, word);
|
||||||
|
@ -22,3 +22,10 @@ function name5 abc --argument-names def ; end
|
|||||||
|
|
||||||
####################
|
####################
|
||||||
# Checking that the copied functions are identical other than the name
|
# Checking that the copied functions are identical other than the name
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Checking reserved names
|
||||||
|
fish: function: The name 'test' is reserved,
|
||||||
|
and can not be used as a function name
|
||||||
|
function test; echo banana; end
|
||||||
|
^
|
||||||
|
@ -46,4 +46,6 @@ logmsg Checking that the copied functions are identical other than the name
|
|||||||
diff (functions name1 | psub) (functions name1a | psub)
|
diff (functions name1 | psub) (functions name1a | psub)
|
||||||
diff (functions name3 | psub) (functions name3a | psub)
|
diff (functions name3 | psub) (functions name3a | psub)
|
||||||
|
|
||||||
|
logmsg Checking reserved names
|
||||||
|
function test; echo banana; end
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -70,3 +70,6 @@ Function name4 not found as expected
|
|||||||
< function name3 --argument arg1 arg2
|
< function name3 --argument arg1 arg2
|
||||||
---
|
---
|
||||||
> function name3a --argument arg1 arg2
|
> function name3a --argument arg1 arg2
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Checking reserved names
|
||||||
|
Loading…
x
Reference in New Issue
Block a user