mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-28 04:51:15 -03:00
add function --shadow-builtin flag
It's currently too easy for someone to bork their shell by doing something like `function test; return 0; end`. That's obviously a silly, contrived, example but the point is that novice users who learn about functions are prone to do something like that without realizing it will bork the shell. Even expert users who know about the `test` builtin might forget that, say, `pwd` is a builtin. This change adds a `--shadow-builtin` flag that must be specified to indicate you know what you're doing. Fixes #3000
This commit is contained in:
@@ -392,8 +392,8 @@ parse_execution_result_t parse_execution_context_t::run_function_statement(
|
||||
int definition_line_offset = this->line_offset_of_character_at_offset(contents_start);
|
||||
wcstring error_str;
|
||||
io_streams_t streams;
|
||||
int err = define_function(*parser, streams, argument_list, contents_str,
|
||||
definition_line_offset, &error_str);
|
||||
int err = builtin_function(*parser, streams, argument_list, contents_str,
|
||||
definition_line_offset, &error_str);
|
||||
proc_set_last_status(err);
|
||||
|
||||
if (!error_str.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user