mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
Fix $SHLVL
Due to being read-only, SHLVL wasn't being incremented properly for recursive invocations of fish.
This commit is contained in:
parent
71ab40e536
commit
130619d6b0
3 changed files with 8 additions and 1 deletions
3
env.cpp
3
env.cpp
|
@ -443,7 +443,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */)
|
|||
L"LINES",
|
||||
L"COLUMNS",
|
||||
L"PWD",
|
||||
L"SHLVL",
|
||||
//L"SHLVL", // will be inserted a bit lower down
|
||||
L"FISH_VERSION",
|
||||
};
|
||||
for (size_t i=0; i < sizeof ro_keys / sizeof *ro_keys; i++)
|
||||
|
@ -549,6 +549,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */)
|
|||
}
|
||||
}
|
||||
env_set(L"SHLVL", nshlvl_str.c_str(), ENV_GLOBAL | ENV_EXPORT);
|
||||
env_read_only.insert(L"SHLVL");
|
||||
|
||||
/* Set up the HOME variable */
|
||||
if (env_get_string(L"HOME").missing_or_empty())
|
||||
|
|
|
@ -233,4 +233,8 @@ echo $testu
|
|||
echo Missing: $testu
|
||||
../fish -c 'echo Missing: $testu'
|
||||
|
||||
# test SHLVL
|
||||
# use a subshell to ensure a clean slate
|
||||
env SHLVL= ../fish -c 'echo SHLVL: $SHLVL; ../fish -c \'echo SHLVL: $SHLVL\''
|
||||
|
||||
true
|
||||
|
|
|
@ -21,3 +21,5 @@ Testing Universal Startup
|
|||
2
|
||||
Missing:
|
||||
Missing:
|
||||
SHLVL: 1
|
||||
SHLVL: 2
|
||||
|
|
Loading…
Reference in a new issue