mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 01:40:28 +00:00
Get execfn the apple way
https://github.com/opensource-apple/dyld/blob/master/src/dyld.cpp#L4789
This commit is contained in:
parent
b3fb6cff43
commit
44a012e3aa
1 changed files with 2 additions and 6 deletions
|
@ -953,13 +953,9 @@ int main(int argc, char **argv, char **envp) {
|
|||
M->lib.dlclose = dlclose;
|
||||
M->lib.dlerror = dlerror;
|
||||
|
||||
/* getenv("_") is close enough to at_execfn */
|
||||
execfn = argc > 0 ? argv[0] : 0;
|
||||
for (i = 0; envp[i]; ++i) {
|
||||
if (envp[i][0] == '_' && envp[i][1] == '=') {
|
||||
execfn = envp[i] + 2;
|
||||
}
|
||||
}
|
||||
execfn = GetEnv(envp + i + 1, "executable_path");
|
||||
|
||||
/* sneak the system five abi back out of args */
|
||||
sp = (long *)(argv - 1);
|
||||
|
@ -994,7 +990,7 @@ int main(int argc, char **argv, char **envp) {
|
|||
M->ps.literally = 0;
|
||||
if (*argv[0] == '-' && (shell = GetEnv(envp, "SHELL")) &&
|
||||
!StrCmp(argv[0] + 1, BaseName(shell))) {
|
||||
execfn = prog = shell;
|
||||
prog = shell;
|
||||
} else {
|
||||
prog = (char *)sp[1];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue