Skip to content

Commit

Permalink
Implement command exit statuses. (bytecodealliance#40)
Browse files Browse the repository at this point in the history
Add a `result` return type to `command` so that it can indicate success
or failure.

The idea here is that this isn't a full `i32` return value because the
meaning of return values isn't portable across platforms. Also, Typed Main
is a better long-term answer for users that want rich error return
values from commands.
  • Loading branch information
sunfishcode authored Dec 24, 2022
1 parent decb08c commit 21ba68b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub unsafe extern "C" fn command(
args_len: usize,
env_vars: StrTupleList,
preopens: PreopenList,
) {
) -> Result<(), ()> {
// TODO: ideally turning off `command` would remove this import and the
// `*.wit` metadata entirely but doing that ergonomically will likely
// require some form of `use` to avoid duplicating lots of `*.wit` bits.
Expand Down Expand Up @@ -86,6 +86,7 @@ pub unsafe extern "C" fn command(
fn _start();
}
_start();
Ok(())
}

// We're avoiding static initializers, so replace the standard assert macros
Expand Down

0 comments on commit 21ba68b

Please sign in to comment.