aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/exec.cpp
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-05-08 15:57:56 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-05-14 20:38:32 -0700
commit51468b764689e7d724a87e6c2b8cdb4e599a3604 (patch)
tree75fe13dbad791e0d143a3610bfe7ed7d0136ad38 /src/exec.cpp
parentff1d651415a2752e82ec417294f9bdf8c234c10f (diff)
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
Diffstat (limited to 'src/exec.cpp')
-rw-r--r--src/exec.cpp4
1 files changed, 2 insertions, 2 deletions
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<wcstring, env_var_t> 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