forked from extern/nushell
Add error codes to -c (#1361)
This commit is contained in:
parent
5f4fae5b06
commit
e606407d79
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 {
|
match line {
|
||||||
LineResult::Success(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));
|
context.maybe_print_errors(Text::from(line));
|
||||||
|
std::process::exit(error_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
LineResult::Error(line, err) => {
|
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));
|
context.maybe_print_errors(Text::from(line));
|
||||||
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
|
Loading…
Reference in New Issue
Block a user