diff --git a/src/lune/process.rs b/src/lune/process.rs index 093c22a..a2085a0 100644 --- a/src/lune/process.rs +++ b/src/lune/process.rs @@ -132,12 +132,15 @@ async fn process_spawn(lua: &Lua, (program, args): (String, Option>) .wait_with_output() .await .map_err(mlua::Error::external)?; - // NOTE: Exit code defaults to 1 if it did not exist and if there - // is any stderr, will otherwise default to 0 if it did not exist + // NOTE: If an exit code was not given by the child process, + // we default to 1 if it yielded any error output, otherwise 0 let code = output .status .code() - .unwrap_or_else(|| i32::from(!output.stderr.is_empty())); + .unwrap_or(match output.stderr.is_empty() { + true => 0, + false => 1, + }); // Construct and return a readonly lua table with results let table = lua.create_table()?; table.raw_set("ok", code == 0)?; diff --git a/src/main.rs b/src/main.rs index cc7f194..699946d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,5 @@ #![deny(clippy::all, clippy::cargo, clippy::pedantic)] -// mlua does not implement userdata for &str -// so in some cases we have to use String -#![allow(clippy::needless_pass_by_value)] +#![allow(clippy::needless_pass_by_value, clippy::match_bool)] use clap::Parser; use mlua::Result;