diff options
Diffstat (limited to 'src/open.zig')
-rw-r--r-- | src/open.zig | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/open.zig b/src/open.zig index 1e1fa317b..16f2e0095 100644 --- a/src/open.zig +++ b/src/open.zig @@ -17,21 +17,21 @@ const opener = switch (@import("builtin").target.os.tag) { else => "xdg-open", }; -pub fn openURL(url: string) !void { - if (comptime Environment.isWasi) { - Output.prettyln("-> {s}", .{url}); - Output.flush(); - return; - } +fn fallback(url: string) void { + Output.prettyln("-> {s}", .{url}); + Output.flush(); +} + +pub fn openURL(url: string) void { + if (comptime Environment.isWasi) return fallback(url); var args_buf = [_]string{ opener, url }; var child_process = std.ChildProcess.init(&args_buf, default_allocator); child_process.stderr_behavior = .Pipe; child_process.stdin_behavior = .Ignore; child_process.stdout_behavior = .Pipe; - try child_process.spawn(); - _ = try child_process.wait(); - return; + child_process.spawn() catch return fallback(url); + _ = child_process.wait() catch return fallback(url); } pub const Editor = enum(u8) { |