aboutsummaryrefslogtreecommitdiff
path: root/misctools
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-11 14:56:28 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-11 14:56:28 -0800
commit3d057950b9249bed3c5b0034ef7424ac84adf2e5 (patch)
treed2f64bbf42890191711571708f110e79990880b2 /misctools
parent29f0159eae198aebf5ff9d2b6f76ddbdb2f8f63c (diff)
downloadbun-3d057950b9249bed3c5b0034ef7424ac84adf2e5.tar.gz
bun-3d057950b9249bed3c5b0034ef7424ac84adf2e5.tar.zst
bun-3d057950b9249bed3c5b0034ef7424ac84adf2e5.zip
`std.os.`exit -> `Global.exit` so stderr is always flushed
Diffstat (limited to 'misctools')
-rw-r--r--misctools/fetch.zig12
-rw-r--r--misctools/http_bench.zig14
2 files changed, 13 insertions, 13 deletions
diff --git a/misctools/fetch.zig b/misctools/fetch.zig
index 2167429e0..f8c06be5d 100644
--- a/misctools/fetch.zig
+++ b/misctools/fetch.zig
@@ -96,7 +96,7 @@ pub const Arguments = struct {
if (args.flag("--version")) {
try Output.writer().writeAll(VERSION);
- std.os.exit(0);
+ Global.exit(0);
}
var method = Method.GET;
@@ -116,13 +116,13 @@ pub const Arguments = struct {
var body_file = std.fs.openFileAbsoluteZ(absolute_path_, .{ .read = true }) catch |err| {
Output.printErrorln("<r><red>{s}<r> opening file {s}", .{ @errorName(err), absolute_path });
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
};
var file_contents = body_file.readToEndAlloc(allocator, try body_file.getEndPos()) catch |err| {
Output.printErrorln("<r><red>{s}<r> reading file {s}", .{ @errorName(err), absolute_path });
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
};
body_string = file_contents;
}
@@ -141,7 +141,7 @@ pub const Arguments = struct {
if (raw_args.items.len == 0) {
Output.prettyErrorln("<r><red>error<r><d>:<r> <b>Missing URL<r>\n\nExample:\n<r><b>fetch GET https://example.com<r>\n\n<b>fetch example.com/foo<r>\n\n", .{});
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
}
const url_position = raw_args.items.len - 1;
@@ -149,7 +149,7 @@ pub const Arguments = struct {
if (!url.isAbsolute()) {
Output.prettyErrorln("<r><red>error<r><d>:<r> <b>Invalid URL<r>\n\nExample:\n<r><b>fetch GET https://example.com<r>\n\n<b>fetch example.com/foo<r>\n\n", .{});
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
}
}
@@ -218,7 +218,7 @@ pub fn main() anyerror!void {
var response = http.response orelse {
Output.prettyErrorln("<r><red>error<r><d>:<r> <b>HTTP response missing<r>", .{});
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
};
switch (response.status_code) {
diff --git a/misctools/http_bench.zig b/misctools/http_bench.zig
index a52229dca..81b81ff13 100644
--- a/misctools/http_bench.zig
+++ b/misctools/http_bench.zig
@@ -102,7 +102,7 @@ pub const Arguments = struct {
if (args.flag("--version")) {
try Output.writer().writeAll(VERSION);
- std.os.exit(0);
+ Global.exit(0);
}
var method = Method.GET;
@@ -122,13 +122,13 @@ pub const Arguments = struct {
var body_file = std.fs.openFileAbsoluteZ(absolute_path_, .{ .read = true }) catch |err| {
Output.printErrorln("<r><red>{s}<r> opening file {s}", .{ @errorName(err), absolute_path });
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
};
var file_contents = body_file.readToEndAlloc(allocator, try body_file.getEndPos()) catch |err| {
Output.printErrorln("<r><red>{s}<r> reading file {s}", .{ @errorName(err), absolute_path });
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
};
body_string = file_contents;
}
@@ -147,7 +147,7 @@ pub const Arguments = struct {
if (raw_args.items.len == 0) {
Output.prettyErrorln("<r><red>error<r><d>:<r> <b>Missing URL<r>\n\nExample:\n<r><b>fetch GET https://example.com<r>\n\n<b>fetch example.com/foo<r>\n\n", .{});
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
}
const url_position = raw_args.items.len - 1;
@@ -155,7 +155,7 @@ pub const Arguments = struct {
if (!url.isAbsolute()) {
Output.prettyErrorln("<r><red>error<r><d>:<r> <b>Invalid URL<r>\n\nExample:\n<r><b>fetch GET https://example.com<r>\n\n<b>fetch example.com/foo<r>\n\n", .{});
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
}
}
@@ -172,12 +172,12 @@ pub const Arguments = struct {
.timeout = std.fmt.parseInt(usize, args.option("--timeout") orelse "0", 10) catch |err| {
Output.prettyErrorln("<r><red>{s}<r> parsing timeout", .{@errorName(err)});
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
},
.count = std.fmt.parseInt(usize, args.option("--count") orelse "10", 10) catch |err| {
Output.prettyErrorln("<r><red>{s}<r> parsing count", .{@errorName(err)});
Output.flush();
- std.os.exit(1);
+ Global.exit(1);
},
};
}