CtrlD exits current shell (#2583)

This commit is contained in:
Chris Gillespie 2020-09-21 00:56:10 -07:00 committed by GitHub
parent a5b6bb6209
commit a508e15efe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -315,7 +315,7 @@ fn convert_rustyline_result_to_string(input: Result<String, ReadlineError>) -> 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<dyn Error>> {
}
}
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<String, ShellError> {