From daf18d35526870e39f3009b6bf9a64d0b4859b9f Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Sat, 31 Jan 2026 20:29:34 -0500 Subject: [PATCH] Exec command directly if subshell fails If execing the child fails, it might be because the shell doesn't exist. Try running the command directly before giving up. --- src/main.zig | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index d7c9a61..734357b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -178,7 +178,36 @@ pub fn main(init: std.process.Init) !void { .stdout = .pipe, .stderr = .ignore, .stdin = .ignore, - }) catch continue; + }) catch |err| switch (err) { + error.AccessDenied, + error.FileBusy, + error.FileNotFound, + error.FileSystem, + error.InvalidExe, + error.IsDir, + error.NotDir, + error.OutOfMemory, + error.PermissionDenied, + error.SymLinkLoop, + error.SystemResources, + => blk: { + var argv_buf: [128][]const u8 = undefined; + var argv: ArrayList([]const u8) = .initBuffer(&argv_buf); + var payload_iter = std.mem.splitAny(u8, connection_payload, " \t\n"); + while (payload_iter.next()) |arg| argv.appendBounded(arg) catch continue; + break :blk std.process.spawn(init.io, .{ + .argv = argv.items, + .stdout = .pipe, + .stderr = .ignore, + .stdin = .ignore, + }) catch continue; + }, + error.Canceled, + error.NoDevice, + error.OperationUnsupported, + => |e| return e, + else => continue, + }; var child_output_buf: [SaprusClient.max_payload_len]u8 = undefined; var child_output_reader = child.stdout.?.reader(init.io, &child_output_buf);