mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 15:46:12 +02:00
update shlvl (only when interactive) on startup
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -280,6 +280,19 @@ fn main() -> Result<()> {
|
|||||||
Value::string(env!("CARGO_PKG_VERSION"), Span::unknown()),
|
Value::string(env!("CARGO_PKG_VERSION"), Span::unknown()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Add SHLVL if interactive
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
if engine_state.is_interactive {
|
||||||
|
let mut shlvl = engine_state
|
||||||
|
.get_env_var("SHLVL")
|
||||||
|
.map(|x| x.as_str().unwrap_or("0").parse::<i64>().unwrap_or(0))
|
||||||
|
.unwrap_or(0);
|
||||||
|
shlvl += 1;
|
||||||
|
engine_state.add_env_var("SHLVL".to_string(), Value::int(shlvl, Span::unknown()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if parsed_nu_cli_args.no_std_lib.is_none() {
|
if parsed_nu_cli_args.no_std_lib.is_none() {
|
||||||
load_standard_library(&mut engine_state)?;
|
load_standard_library(&mut engine_state)?;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user