mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-21 06:31:13 -03:00
Also set the read-only flag for non-electric vars
For some reason, we have two places where a variable can be read-only: - By key in env.cpp:is_read_only(), which is checked via set* - By flag on the actual env_var_t, which is checked e.g. in parse_execution The latter didn't happen for non-electric variables like hostname, because they used the default constructor, because they were constructed via operator[] (or some such C++-iness). This caused for-loops to crash on an assert if they used a non-electric read-only var like $hostname or $SHLVL. Instead, we explicitly set the flag. We might want to remove one of the two read-only checks, or something? Fixes #5548.
This commit is contained in:
@@ -1221,6 +1221,7 @@ int env_stack_t::set_internal(const wcstring &key, env_mode_flags_t input_var_mo
|
||||
|
||||
var.set_vals(std::move(val));
|
||||
var.set_pathvar(var_mode & ENV_PATHVAR);
|
||||
var.set_read_only(is_read_only(key));
|
||||
|
||||
if (var_mode & ENV_EXPORT) {
|
||||
// The new variable is exported.
|
||||
|
||||
Reference in New Issue
Block a user