diff options
author | 2023-01-16 16:28:02 -0800 | |
---|---|---|
committer | 2023-01-16 16:28:02 -0800 | |
commit | 7dd28bbdd99b31cc88abe4b309ed52aff64be9c2 (patch) | |
tree | ae3b2c0ae4d790995801a59de78fdb3fd5c896af /src/which.zig | |
parent | d54e23ca33cc95199a58d958abf990d9a6e1eb26 (diff) | |
download | bun-7dd28bbdd99b31cc88abe4b309ed52aff64be9c2.tar.gz bun-7dd28bbdd99b31cc88abe4b309ed52aff64be9c2.tar.zst bun-7dd28bbdd99b31cc88abe4b309ed52aff64be9c2.zip |
Fix `which` returning directories sometimes
Diffstat (limited to '')
-rw-r--r-- | src/which.zig | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/which.zig b/src/which.zig index 6c0828e7b..abf5d57f7 100644 --- a/src/which.zig +++ b/src/which.zig @@ -10,11 +10,9 @@ fn isValid(buf: *[bun.MAX_PATH_BYTES]u8, segment: []const u8, bin: []const u8) ? return @intCast(u16, filepath.len); } +extern "C" fn is_executable_file(path: [*:0]const u8) bool; fn checkPath(filepath: [:0]const u8) bool { - // TODO: is there a single system call for executable AND file? - std.os.accessZ(filepath, std.os.X_OK) catch return false; - std.os.accessZ(filepath, std.os.F_OK) catch return false; - return true; + return is_executable_file(filepath); } // Like /usr/bin/which but without needing to exec a child process |