mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 18:00:28 +00:00
Fix execfn
This is good enough, and better than argv[0] in most cases.
This commit is contained in:
parent
eddebe8db5
commit
2e3668b430
1 changed files with 3 additions and 3 deletions
|
@ -966,6 +966,9 @@ int main(int argc, char **argv, char **envp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prog = GetEnv(envp + i + 1, "executable_path");
|
prog = GetEnv(envp + i + 1, "executable_path");
|
||||||
|
if (!execfn) {
|
||||||
|
execfn = prog;
|
||||||
|
}
|
||||||
|
|
||||||
/* sneak the system five abi back out of args */
|
/* sneak the system five abi back out of args */
|
||||||
sp = (long *)(argv - 1);
|
sp = (long *)(argv - 1);
|
||||||
|
@ -1021,9 +1024,6 @@ int main(int argc, char **argv, char **envp) {
|
||||||
argc = sp[1] = sp[0] - 1;
|
argc = sp[1] = sp[0] - 1;
|
||||||
argv = (char **)((sp += 1) + 1);
|
argv = (char **)((sp += 1) + 1);
|
||||||
}
|
}
|
||||||
if (!execfn) {
|
|
||||||
execfn = prog;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate ephemeral memory for reading file */
|
/* allocate ephemeral memory for reading file */
|
||||||
n = sizeof(union ElfEhdrBuf);
|
n = sizeof(union ElfEhdrBuf);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue