2023-08-09 06:17:10 +08:00
|
|
|
use super::prelude::*;
|
2023-02-19 00:13:58 +08:00
|
|
|
use super::r#return::parse_return_value;
|
|
|
|
|
|
|
|
/// Function for handling the exit builtin.
|
2023-10-09 05:22:27 +08:00
|
|
|
pub fn exit(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Option<c_int> {
|
2023-02-19 00:13:58 +08:00
|
|
|
let retval = match parse_return_value(args, parser, streams) {
|
|
|
|
Ok(v) => v,
|
|
|
|
Err(e) => return e,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Mark that we are exiting in the parser.
|
|
|
|
// TODO: in concurrent mode this won't successfully exit a pipeline, as there are other parsers
|
|
|
|
// involved. That is, `exit | sleep 1000` may not exit as hoped. Need to rationalize what
|
|
|
|
// behavior we want here.
|
2023-10-09 05:22:27 +08:00
|
|
|
parser.libdata_mut().pods.exit_current_script = true;
|
2023-02-19 00:13:58 +08:00
|
|
|
|
|
|
|
return Some(retval);
|
|
|
|
}
|