mirror of
https://github.com/nushell/nushell
synced 2024-12-26 04:53:09 +00:00
Add error codes to -c (#1361)
This commit is contained in:
parent
5f4fae5b06
commit
e606407d79
1 changed files with 13 additions and 0 deletions
13
src/cli.rs
13
src/cli.rs
|
@ -394,7 +394,19 @@ pub async fn run_pipeline_standalone(pipeline: String) -> Result<(), Box<dyn Err
|
|||
|
||||
match line {
|
||||
LineResult::Success(line) => {
|
||||
let error_code = {
|
||||
let errors = context.current_errors.clone();
|
||||
let errors = errors.lock();
|
||||
|
||||
if errors.len() > 0 {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
context.maybe_print_errors(Text::from(line));
|
||||
std::process::exit(error_code);
|
||||
}
|
||||
|
||||
LineResult::Error(line, err) => {
|
||||
|
@ -403,6 +415,7 @@ pub async fn run_pipeline_standalone(pipeline: String) -> Result<(), Box<dyn Err
|
|||
});
|
||||
|
||||
context.maybe_print_errors(Text::from(line));
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
_ => {}
|
||||
|
|
Loading…
Reference in a new issue