From 21ba68b41bf287965c50d62e1aaf0bf0e11a0d4f Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 23 Dec 2022 20:00:48 -0800 Subject: [PATCH] Implement `command` exit statuses. (#40) 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. --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f8d99b45837f..5ad723e77266 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. @@ -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