mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 04:13:08 +00:00
Revert "Non-exported vars: rename SHLVL to shlvl"
Duh, of course it is exported.
This reverts commit 5fc17dcc82
.
This commit is contained in:
parent
5fc17dcc82
commit
a9283803d4
5 changed files with 24 additions and 24 deletions
|
@ -868,7 +868,7 @@ The user can change the settings of `fish` by changing the values of certain var
|
|||
|
||||
- `version`, the version of the currently running fish
|
||||
|
||||
- `shlvl`, the level of nesting of shells
|
||||
- `SHLVL`, the level of nesting of shells
|
||||
|
||||
- `COLUMNS` and `LINES`, the current size of the terminal in height and width. These values are only used by fish if the operating system does not report the size of the terminal. Both variables must be set in that case otherwise a default of 80x24 will be used. They are updated when the window size changes.
|
||||
|
||||
|
|
10
src/env.cpp
10
src/env.cpp
|
@ -862,7 +862,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
wcstring(L"PWD"),
|
||||
wcstring(L"version") }) {
|
||||
env_read_only.emplace(std::move(k));
|
||||
// L"shlvl" is readonly but will be inserted below after we increment it.
|
||||
// L"SHLVL" is readonly but will be inserted below after we increment it.
|
||||
};
|
||||
|
||||
// Names of all dynamically calculated variables.
|
||||
|
@ -928,8 +928,8 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
wcstring version = str2wcstring(get_fish_version());
|
||||
env_set_one(L"version", ENV_GLOBAL, version);
|
||||
|
||||
// Set up shlvl variable.
|
||||
const auto shlvl_var = env_get(L"shlvl");
|
||||
// Set up SHLVL variable.
|
||||
const auto shlvl_var = env_get(L"SHLVL");
|
||||
wcstring nshlvl_str = L"1";
|
||||
if (!shlvl_var.missing_or_empty()) {
|
||||
const wchar_t *end;
|
||||
|
@ -939,8 +939,8 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
nshlvl_str = to_string<long>(shlvl_i + 1);
|
||||
}
|
||||
}
|
||||
env_set_one(L"shlvl", ENV_GLOBAL | ENV_EXPORT, nshlvl_str);
|
||||
env_read_only.emplace(L"shlvl");
|
||||
env_set_one(L"SHLVL", ENV_GLOBAL | ENV_EXPORT, nshlvl_str);
|
||||
env_read_only.emplace(L"SHLVL");
|
||||
|
||||
// Set up the HOME variable.
|
||||
// Unlike $USER, it doesn't seem that `su`s pass this along
|
||||
|
|
|
@ -375,8 +375,8 @@ void internal_exec(job_t *j, const io_chain_t &&all_ios) {
|
|||
// commands in the pipeline will apply to exec. However, using exec in a pipeline doesn't
|
||||
// really make sense, so I'm not trying to fix it here.
|
||||
if (!setup_child_process(0, all_ios)) {
|
||||
// Decrement shlvl as we're removing ourselves from the shell "stack".
|
||||
auto shlvl_var = env_get(L"shlvl", ENV_GLOBAL | ENV_EXPORT);
|
||||
// Decrement SHLVL as we're removing ourselves from the shell "stack".
|
||||
auto shlvl_var = env_get(L"SHLVL", ENV_GLOBAL | ENV_EXPORT);
|
||||
wcstring shlvl_str = L"0";
|
||||
if (shlvl_var) {
|
||||
long shlvl = fish_wcstol(shlvl_var->as_string().c_str());
|
||||
|
@ -384,7 +384,7 @@ void internal_exec(job_t *j, const io_chain_t &&all_ios) {
|
|||
shlvl_str = to_string<long>(shlvl - 1);
|
||||
}
|
||||
}
|
||||
env_set_one(L"shlvl", ENV_GLOBAL | ENV_EXPORT, shlvl_str);
|
||||
env_set_one(L"SHLVL", ENV_GLOBAL | ENV_EXPORT, shlvl_str);
|
||||
|
||||
// launch_process _never_ returns.
|
||||
launch_process_nofork(j->processes.front().get());
|
||||
|
|
|
@ -285,16 +285,16 @@ set -q testu
|
|||
or echo testu undef in top level shell
|
||||
../test/root/bin/fish -c 'set -q testu; or echo testu undef in sub shell'
|
||||
|
||||
# test shlvl
|
||||
# test SHLVL
|
||||
# use a subshell to ensure a clean slate
|
||||
env shlvl= ../test/root/bin/fish -c 'echo shlvl: $shlvl; ../test/root/bin/fish -c \'echo shlvl: $shlvl\''
|
||||
# exec should decrement shlvl
|
||||
env shlvl= ../test/root/bin/fish -c 'echo shlvl: $shlvl; exec ../test/root/bin/fish -c \'echo shlvl: $shlvl\''
|
||||
# garbage shlvls should be treated as garbage
|
||||
env shlvl=3foo ../test/root/bin/fish -c 'echo shlvl: $shlvl'
|
||||
env SHLVL= ../test/root/bin/fish -c 'echo SHLVL: $SHLVL; ../test/root/bin/fish -c \'echo SHLVL: $SHLVL\''
|
||||
# exec should decrement SHLVL
|
||||
env SHLVL= ../test/root/bin/fish -c 'echo SHLVL: $SHLVL; exec ../test/root/bin/fish -c \'echo SHLVL: $SHLVL\''
|
||||
# garbage SHLVLs should be treated as garbage
|
||||
env SHLVL=3foo ../test/root/bin/fish -c 'echo SHLVL: $SHLVL'
|
||||
# whitespace is allowed though (for bash compatibility)
|
||||
env shlvl="3 " ../test/root/bin/fish -c 'echo shlvl: $shlvl'
|
||||
env shlvl=" 3" ../test/root/bin/fish -c 'echo shlvl: $shlvl'
|
||||
env SHLVL="3 " ../test/root/bin/fish -c 'echo SHLVL: $SHLVL'
|
||||
env SHLVL=" 3" ../test/root/bin/fish -c 'echo SHLVL: $SHLVL'
|
||||
|
||||
# Test transformation of inherited variables
|
||||
env DISPLAY="localhost:0.0" ../test/root/bin/fish -c 'echo Elements in DISPLAY: (count $DISPLAY)'
|
||||
|
|
|
@ -33,13 +33,13 @@ Testing Universal Startup
|
|||
2
|
||||
testu undef in top level shell
|
||||
testu undef in sub shell
|
||||
shlvl: 1
|
||||
shlvl: 2
|
||||
shlvl: 1
|
||||
shlvl: 1
|
||||
shlvl: 1
|
||||
shlvl: 4
|
||||
shlvl: 4
|
||||
SHLVL: 1
|
||||
SHLVL: 2
|
||||
SHLVL: 1
|
||||
SHLVL: 1
|
||||
SHLVL: 1
|
||||
SHLVL: 4
|
||||
SHLVL: 4
|
||||
Elements in DISPLAY: 1
|
||||
Elements in FOO: 4
|
||||
MANPATH=man1:man2:man3
|
||||
|
|
Loading…
Reference in a new issue