From 51468b764689e7d724a87e6c2b8cdb4e599a3604 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Sun, 8 May 2016 15:57:56 -0700 Subject: 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 --- src/builtin.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/builtin.h') diff --git a/src/builtin.h b/src/builtin.h index 0d62babe..7648649d 100644 --- a/src/builtin.h +++ b/src/builtin.h @@ -93,10 +93,10 @@ class builtin_commandline_scoped_transient_t { // Run the __fish_print_help function to obtain the help information for the specified command. wcstring builtin_help_get(parser_t &parser, const wchar_t *cmd); -// Defines a function, like builtin_function. Returns 0 on success. args should NOT contain -// 'function' as the first argument. -int define_function(parser_t &parser, io_streams_t &streams, const wcstring_list_t &c_args, - const wcstring &contents, int definition_line_offset, wcstring *out_err); +// Defines a function. Returns 0 on success. args should NOT contain 'function' as the first +// argument as the parser treats it as a keyword. +int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_list_t &c_args, + const wcstring &contents, int definition_line_offset, wcstring *out_err); // Print help for the specified builtin. If \c b is sb_err, also print the line information. void builtin_print_help(parser_t &parser, io_streams_t &streams, const wchar_t *cmd, -- cgit v1.2.3