From a9283803d40913059fddc21c79b46447dd2a0a90 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Sun, 15 Oct 2017 04:37:34 -0700 Subject: [PATCH] Revert "Non-exported vars: rename SHLVL to shlvl" Duh, of course it is exported. This reverts commit 5fc17dcc826fd8fe7562c4b8293bff1e31472744. --- doc_src/index.hdr.in | 2 +- src/env.cpp | 10 +++++----- src/exec.cpp | 6 +++--- tests/test3.in | 16 ++++++++-------- tests/test3.out | 14 +++++++------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/doc_src/index.hdr.in b/doc_src/index.hdr.in index 04385380d..e7e66fbac 100644 --- a/doc_src/index.hdr.in +++ b/doc_src/index.hdr.in @@ -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. diff --git a/src/env.cpp b/src/env.cpp index 0d3559d62..e84e13750 100644 --- a/src/env.cpp +++ b/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(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 diff --git a/src/exec.cpp b/src/exec.cpp index 7d7a9114f..a390cfcb3 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -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(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()); diff --git a/tests/test3.in b/tests/test3.in index 192f13af1..dacf46144 100644 --- a/tests/test3.in +++ b/tests/test3.in @@ -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)' diff --git a/tests/test3.out b/tests/test3.out index 811ab949c..762548f59 100644 --- a/tests/test3.out +++ b/tests/test3.out @@ -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