aboutsummaryrefslogtreecommitdiffhomepage
path: root/builtin_set.cpp
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-07-12 14:05:42 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-07-12 14:07:55 -0700
commit2457997cd9c624034f28f1be218f93cdc60a3e58 (patch)
treef22631d0f695b2cea31aa4b7fcb61b641b2e391c /builtin_set.cpp
parentd9bed68fe9af4502c62ff19bc27b0c4fca4034a6 (diff)
set: Print an error when setting a special var in the wrong scope
When attempting to set a readonly or electric variable in the local or universal scopes, print an appropriate error. Similarly, print an error when setting an electric variable as exported. In most cases this is simply a nicer error instead of the 'read-only' one, but for the 'umask' variable it prevents `set -l umask 0023` from silently changing the global value.
Diffstat (limited to 'builtin_set.cpp')
-rw-r--r--builtin_set.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/builtin_set.cpp b/builtin_set.cpp
index 9068372f..aae87550 100644
--- a/builtin_set.cpp
+++ b/builtin_set.cpp
@@ -157,6 +157,13 @@ static int my_env_set(const wchar_t *key, const wcstring_list_t &val, int scope)
break;
}
+ case ENV_SCOPE:
+ {
+ append_format(stderr_buffer, _(L"%ls: Tried to set the special variable '%ls' with the wrong scope\n"), L"set", key);
+ retcode=1;
+ break;
+ }
+
case ENV_INVALID:
{
append_format(stderr_buffer, _(L"%ls: Unknown error"), L"set");