From a508e15efe406856b27af5aa20328dbb790673eb Mon Sep 17 00:00:00 2001 From: Chris Gillespie <6572184+gillespiecd@users.noreply.github.com> Date: Mon, 21 Sep 2020 00:56:10 -0700 Subject: [PATCH] CtrlD exits current shell (#2583) --- crates/nu-cli/src/cli.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/nu-cli/src/cli.rs b/crates/nu-cli/src/cli.rs index ddea60394a..99caba38bd 100644 --- a/crates/nu-cli/src/cli.rs +++ b/crates/nu-cli/src/cli.rs @@ -315,7 +315,7 @@ fn convert_rustyline_result_to_string(input: Result) -> L match input { Ok(s) => LineResult::Success(s), Err(ReadlineError::Interrupted) => LineResult::CtrlC, - Err(ReadlineError::Eof) => LineResult::Break, + Err(ReadlineError::Eof) => LineResult::CtrlD, Err(err) => { outln!("Error: {:?}", err); LineResult::Break @@ -525,6 +525,13 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box> { } } + LineResult::CtrlD => { + context.shell_manager.remove_at_current(); + if context.shell_manager.is_empty() { + break; + } + } + LineResult::Break => { break; } @@ -830,8 +837,9 @@ fn chomp_newline(s: &str) -> &str { pub enum LineResult { Success(String), Error(String, ShellError), - CtrlC, Break, + CtrlC, + CtrlD, } pub async fn parse_and_eval(line: &str, ctx: &mut EvaluationContext) -> Result {