From f85ec782a0f8aaae84e8730a6847748f03f1256f Mon Sep 17 00:00:00 2001 From: David Adam Date: Mon, 6 Oct 2014 15:10:56 +0800 Subject: [PATCH] set: warn on setting a universal variable when a global is active Closes #806. --- builtin_set.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/builtin_set.cpp b/builtin_set.cpp index eb4f5eda5..0434311b3 100644 --- a/builtin_set.cpp +++ b/builtin_set.cpp @@ -807,6 +807,16 @@ static int builtin_set(parser_t &parser, wchar_t **argv) } } + /* Check if we are setting variables above the effective scope. + See https://github.com/fish-shell/fish-shell/issues/806 + */ + + env_var_t global_dest = env_get_string(dest, ENV_GLOBAL); + if (universal && ! global_dest.missing()) + { + append_format(stderr_buffer, _(L"%ls: Warning: universal scope selected, but a global variable %ls exists.\n"), L"set", dest); + } + free(dest); if (retcode == STATUS_BUILTIN_OK && preserve_incoming_failure_exit_status)