diff options
author | 2021-12-28 04:04:29 -0800 | |
---|---|---|
committer | 2021-12-28 04:04:29 -0800 | |
commit | 565cf23d9263ea153b8cb7d6f67a6c534b40ceeb (patch) | |
tree | d08a4814021aa092ba5872b4990e01aa06a8e504 | |
parent | 020e2e00c38122a96afd5a3ccc70e6db00e086ef (diff) | |
download | bun-565cf23d9263ea153b8cb7d6f67a6c534b40ceeb.tar.gz bun-565cf23d9263ea153b8cb7d6f67a6c534b40ceeb.tar.zst bun-565cf23d9263ea153b8cb7d6f67a6c534b40ceeb.zip |
More defensively search for shells to use if one is not found in the path
-rw-r--r-- | src/cli/run_command.zig | 22 |
1 files changed, 22 insertions, 0 deletions
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; } |