Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions crates/nu-command/src/default_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,7 @@ pub fn create_default_context() -> EngineState {

// Shells
bind_command! {
Enter,
Exit,
GotoShell,
NextShell,
PrevShell,
Shells,
};

// Formats
Expand Down
18 changes: 0 additions & 18 deletions crates/nu-command/src/filesystem/cd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::filesystem::cd_query::query;
use crate::{get_current_shell, get_shells};
#[cfg(unix)]
use libc::gid_t;
use nu_engine::{current_dir, CallExt};
Expand Down Expand Up @@ -164,23 +163,6 @@ impl Command for Cd {
val: path.clone(),
span,
};
let cwd = Value::string(cwd.to_string_lossy(), call.head);

let mut shells = get_shells(engine_state, stack, cwd);
let current_shell = get_current_shell(engine_state, stack);
shells[current_shell] = path_value.clone();

stack.add_env_var(
"NUSHELL_SHELLS".into(),
Value::List {
vals: shells,
span: call.head,
},
);
stack.add_env_var(
"NUSHELL_CURRENT_SHELL".into(),
Value::int(current_shell as i64, call.head),
);

if let Some(oldpwd) = stack.get_env_var(engine_state, "PWD") {
stack.add_env_var("OLDPWD".into(), oldpwd)
Expand Down
103 changes: 0 additions & 103 deletions crates/nu-command/src/shells/enter.rs

This file was deleted.

76 changes: 8 additions & 68 deletions crates/nu-command/src/shells/exit.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use super::{get_current_shell, get_last_shell, get_shells};
use nu_engine::{current_dir, CallExt};
use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};

#[derive(Clone)]
pub struct Exit;
Expand All @@ -22,11 +19,6 @@ impl Command for Exit {
SyntaxShape::Int,
"Exit code to return immediately with",
)
.switch(
"now",
"Exit out of all shells immediately (exiting Nu)",
Some('n'),
)
.category(Category::Shells)
}

Expand All @@ -51,66 +43,14 @@ impl Command for Exit {
std::process::exit(exit_code as i32);
}

if call.has_flag("now") {
std::process::exit(0);
}

let cwd = current_dir(engine_state, stack)?;
let cwd = Value::string(cwd.to_string_lossy(), call.head);

let mut shells = get_shells(engine_state, stack, cwd);
let mut current_shell = get_current_shell(engine_state, stack);
let mut last_shell = get_last_shell(engine_state, stack);

shells.remove(current_shell);

if current_shell <= last_shell {
last_shell = 0;
}

if current_shell == shells.len() && !shells.is_empty() {
current_shell -= 1;
}

if shells.is_empty() {
std::process::exit(0);
} else {
let new_path = shells[current_shell].clone();

stack.add_env_var(
"NUSHELL_SHELLS".into(),
Value::List {
vals: shells,
span: call.head,
},
);
stack.add_env_var(
"NUSHELL_CURRENT_SHELL".into(),
Value::int(current_shell as i64, call.head),
);
stack.add_env_var(
"NUSHELL_LAST_SHELL".into(),
Value::int(last_shell as i64, call.head),
);

stack.add_env_var("PWD".into(), new_path);

Ok(PipelineData::empty())
}
std::process::exit(0);
}

fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Exit the current shell",
example: "exit",
result: None,
},
Example {
description: "Exit all shells (exiting Nu)",
example: "exit --now",
result: None,
},
]
vec![Example {
description: "Exit the current shell",
example: "exit",
result: None,
}]
}
}
97 changes: 0 additions & 97 deletions crates/nu-command/src/shells/g.rs

This file was deleted.

Loading