From 565cf23d9263ea153b8cb7d6f67a6c534b40ceeb Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Tue, 28 Dec 2021 04:04:29 -0800 Subject: More defensively search for shells to use if one is not found in the path --- src/cli/run_command.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index 9dd1570c5..ae9dfd715 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -49,6 +49,28 @@ pub const RunCommand = struct { } } + const Try = struct { + pub fn shell(str: stringZ) bool { + std.os.accessZ(str, std.os.X_OK) catch return false; + return true; + } + }; + + const hardcoded_popular_ones = [_]stringZ{ + "/bin/bash", + "/usr/bin/bash", + "/usr/local/bin/bash", // don't think this is a real one + "/bin/sh", + "/usr/bin/sh", // don't think this is a real one + "/usr/bin/zsh", + "/usr/local/bin/zsh", + }; + inline for (hardcoded_popular_ones) |shell| { + if (Try.shell(shell)) { + return shell; + } + } + return null; } -- cgit v1.2.3