commit 5bfc6935a53af99880e9220f990b458b29177c90
parent a4b2fbea8c5f98f09c5b9e07bfe987d0e277f2a0
Author: Sebastian <sebastian@sebsite.pw>
Date: Fri, 8 Sep 2023 00:21:21 -0400
all: use os::status in os::exit calls
...with the exception of 'log', which I changed to exit with status 255,
to mirror fmt::fatal et al.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/cmd/hare/build.ha b/cmd/hare/build.ha
@@ -123,7 +123,7 @@ fn build(name: str, cmd: *getopt::command) (void | error) = {
};
if (len(cmd.args) > 1 && name == "build") {
getopt::printusage(os::stderr, name, cmd.help...)!;
- os::exit(1);
+ os::exit(os::status::FAILURE);
};
ctx.arch = arch.qbe_name;
diff --git a/cmd/hare/deps.ha b/cmd/hare/deps.ha
@@ -40,7 +40,7 @@ fn deps(name: str, cmd: *getopt::command) (void | error) = {
if (len(cmd.args) > 1) {
getopt::printusage(os::stderr, name, cmd.help...)!;
- os::exit(1);
+ os::exit(os::status::FAILURE);
};
const input = if (len(cmd.args) == 0) os::getcwd() else cmd.args[0];
diff --git a/cmd/hare/main.ha b/cmd/hare/main.ha
@@ -81,7 +81,7 @@ export fn main() void = {
match (cmd.subcmd) {
case void =>
getopt::printusage(os::stderr, os::args[0], help...)!;
- os::exit(1);
+ os::exit(os::status::FAILURE);
case let subcmd: (str, *getopt::command) =>
const task = switch (subcmd.0) {
case "build", "run", "test" =>
diff --git a/getopt/getopts.ha b/getopt/getopts.ha
@@ -67,7 +67,7 @@ export type error = !(
);
// A wrapper for [[tryparse]] in which if an error occurs, details are printed
-// to [[os::stderr]] and [[os::exit]] is called with a nonzero exit status.
+// to [[os::stderr]] and [[os::exit]] is called with [[os::status::FAILURE]].
export fn parse(args: []str, help: help...) command = {
match (tryparse(args, help...)) {
case let c: command => return c;
@@ -83,7 +83,7 @@ export fn parse(args: []str, help: help...) command = {
fmt::errorln()!;
};
printusage(os::stderr, e.0, e.1)!;
- os::exit(1);
+ os::exit(os::status::FAILURE);
};
};
@@ -138,7 +138,7 @@ export fn tryparse(args: []str, help: help...) (command | error) = {
if (found) continue;
if (r =='h') {
printhelp(os::stderr, args[0], help)!;
- os::exit(0);
+ os::exit(os::status::SUCCESS);
};
free(opts);
return (args[0], help, r: unknown_option): error;
diff --git a/log/funcs.ha b/log/funcs.ha
@@ -24,7 +24,7 @@ export fn printfln(fmt: str, fields: fmt::field...) void = {
// Prints data to the log with a newline, then terminates the process.
export fn lfatal(log: *logger, fields: fmt::formattable...) never = {
lprintln(log, fields...);
- os::exit(1);
+ os::exit(255);
};
// Formats and prints data to the log with new line, then terminates the
@@ -35,18 +35,18 @@ export fn lfatalf(
fields: fmt::field...
) never = {
lprintfln(log, fmt, fields...);
- os::exit(1);
+ os::exit(255);
};
// Prints data to the global log with new line, then terminates the process.
export fn fatal(fields: fmt::formattable...) never = {
lprintln(global, fields...);
- os::exit(1);
+ os::exit(255);
};
// Formats and prints data to the global log with new line, then terminates the
// process.
export fn fatalf(fmt: str, fields: fmt::field...) never = {
lprintfln(global, fmt, fields...);
- os::exit(1);
+ os::exit(255);
};
diff --git a/test/fail+test.ha b/test/fail+test.ha
@@ -7,5 +7,5 @@ use os;
@test fn exit() void = {
expectabort();
- os::exit(1);
+ os::exit(os::status::FAILURE);
};