mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 05:41:16 -03:00
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.
This commit is contained in:
2
env.h
2
env.h
@@ -49,6 +49,7 @@
|
||||
enum
|
||||
{
|
||||
ENV_PERM = 1,
|
||||
ENV_SCOPE,
|
||||
ENV_INVALID
|
||||
}
|
||||
;
|
||||
@@ -82,6 +83,7 @@ void env_init(const struct config_paths_t *paths = NULL);
|
||||
The current error codes are:
|
||||
|
||||
* ENV_PERM, can only be returned when setting as a user, e.g. ENV_USER is set. This means that the user tried to change a read-only variable.
|
||||
* ENV_SCOPE, the variable cannot be set in the given scope. This applies to readonly/electric variables set from the local or universal scopes, or set as exported.
|
||||
* ENV_INVALID, the variable name or mode was invalid
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user