mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
os: don't return stack memory
A regression from adcaff7137ef
This commit is contained in:

committed by
Jonathan Lopez

parent
a300c0c153
commit
5559eaa235
@ -18,7 +18,31 @@ pub fn open(
|
|||||||
typ: Type,
|
typ: Type,
|
||||||
url: []const u8,
|
url: []const u8,
|
||||||
) !void {
|
) !void {
|
||||||
const cmd = try openCommand(alloc, typ, url);
|
const cmd: OpenCommand = switch (builtin.os.tag) {
|
||||||
|
.linux => .{ .child = std.process.Child.init(
|
||||||
|
&.{ "xdg-open", url },
|
||||||
|
alloc,
|
||||||
|
) },
|
||||||
|
|
||||||
|
.windows => .{ .child = std.process.Child.init(
|
||||||
|
&.{ "rundll32", "url.dll,FileProtocolHandler", url },
|
||||||
|
alloc,
|
||||||
|
) },
|
||||||
|
|
||||||
|
.macos => .{
|
||||||
|
.child = std.process.Child.init(
|
||||||
|
switch (typ) {
|
||||||
|
.text => &.{ "open", "-t", url },
|
||||||
|
.unknown => &.{ "open", url },
|
||||||
|
},
|
||||||
|
alloc,
|
||||||
|
),
|
||||||
|
.wait = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
.ios => return error.Unimplemented,
|
||||||
|
else => @compileError("unsupported OS"),
|
||||||
|
};
|
||||||
|
|
||||||
var exe = cmd.child;
|
var exe = cmd.child;
|
||||||
if (cmd.wait) {
|
if (cmd.wait) {
|
||||||
@ -53,31 +77,3 @@ const OpenCommand = struct {
|
|||||||
child: std.process.Child,
|
child: std.process.Child,
|
||||||
wait: bool = false,
|
wait: bool = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn openCommand(alloc: Allocator, typ: Type, url: []const u8) !OpenCommand {
|
|
||||||
return switch (builtin.os.tag) {
|
|
||||||
.linux => .{ .child = std.process.Child.init(
|
|
||||||
&.{ "xdg-open", url },
|
|
||||||
alloc,
|
|
||||||
) },
|
|
||||||
|
|
||||||
.windows => .{ .child = std.process.Child.init(
|
|
||||||
&.{ "rundll32", "url.dll,FileProtocolHandler", url },
|
|
||||||
alloc,
|
|
||||||
) },
|
|
||||||
|
|
||||||
.macos => .{
|
|
||||||
.child = std.process.Child.init(
|
|
||||||
switch (typ) {
|
|
||||||
.text => &.{ "open", "-t", url },
|
|
||||||
.unknown => &.{ "open", url },
|
|
||||||
},
|
|
||||||
alloc,
|
|
||||||
),
|
|
||||||
.wait = true,
|
|
||||||
},
|
|
||||||
|
|
||||||
.ios => return error.Unimplemented,
|
|
||||||
else => @compileError("unsupported OS"),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user