Skip to content

Commit b679891

Browse files
[thisroot] resolve reexec sh on macos
On MacOS, sh re-executes as another shell. This tripped the logic in thisroot that's trying to find out which shell is running. Fixes #19965 Co-authored-by: Stephan Hageboeck <[email protected]>
1 parent c949817 commit b679891

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

config/thisroot.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ getTrueShellExeName() { # mklement0 https://stackoverflow.com/a/23011530/7471760
189189
# If the executable is a symlink, resolve it to its *ultimate*
190190
# target.
191191
while nextTarget=$(readlink "$trueExe"); do trueExe=$nextTarget; done
192+
193+
if [ "$(basename $trueExe)" = "sh" -a -L "/private/var/select/sh" ]; then
194+
# on MacOS, sh re-execs /private/var/select/sh, so resolve it
195+
trueExe="/private/var/select/sh";
196+
while nextTarget=$(readlink "$trueExe"); do trueExe=$nextTarget; done
197+
fi
192198
# Output the executable name only.
193199
printf '%s' "$(basename "$trueExe")"
194200
}

0 commit comments

Comments
 (0)