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/exec.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/exec.cpp') diff --git a/src/exec.cpp b/src/exec.cpp index 24a9af05..63f2cb77 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -636,7 +636,7 @@ void exec_job(parser_t &parser, job_t *j) { wcstring def; bool function_exists = function_get_definition(func_name, &def); - bool shadows = function_get_shadows(func_name); + bool shadow_scope = function_get_shadow_scope(func_name); const std::map inherit_vars = function_get_inherit_vars(func_name); @@ -646,7 +646,7 @@ void exec_job(parser_t &parser, job_t *j) { debug(0, _(L"Unknown function '%ls'"), p->argv0()); break; } - function_block_t *newv = new function_block_t(p, func_name, shadows); + function_block_t *newv = new function_block_t(p, func_name, shadow_scope); parser.push_block(newv); // Setting variables might trigger an event handler, hence we need to unblock -- cgit v1.2.3