mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 19:30:29 +00:00
Prioritize argv[0]
Using `COSMOPOLITAN_PROGRAM_EXECUTABLE` without a `sys_faccessat` was rightly causing test failures. Now that it is no longer used by the loader, there seems little value in prioritizing it over argv[0], so just lump it in with "_".
This commit is contained in:
parent
c8395bf2f3
commit
42bf4d2a9f
1 changed files with 4 additions and 8 deletions
|
@ -116,12 +116,6 @@ static inline void InitProgramExecutableNameImpl(void) {
|
||||||
goto UseEmpty;
|
goto UseEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the previous loader supplied the full program path as the first
|
|
||||||
environment variable. */
|
|
||||||
if ((q = __getenv(__envp, "COSMOPOLITAN_PROGRAM_EXECUTABLE").s)) {
|
|
||||||
goto CopyString;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if argv[0] exists then turn it into an absolute path. we also try
|
// if argv[0] exists then turn it into an absolute path. we also try
|
||||||
// adding a .com suffix since the ape auto-appends it when resolving
|
// adding a .com suffix since the ape auto-appends it when resolving
|
||||||
if ((q = __argv[0])) {
|
if ((q = __argv[0])) {
|
||||||
|
@ -149,8 +143,10 @@ static inline void InitProgramExecutableNameImpl(void) {
|
||||||
if (!sys_faccessat(AT_FDCWD, g_prog.u.buf, F_OK, 0)) goto UseBuf;
|
if (!sys_faccessat(AT_FDCWD, g_prog.u.buf, F_OK, 0)) goto UseBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if getenv("_") exists then use that
|
/* the previous loader supplied the full program path as the first
|
||||||
if ((q = __getenv(__envp, "_").s)) {
|
environment variable. we also try "_". */
|
||||||
|
if ((q = __getenv(__envp, "COSMOPOLITAN_PROGRAM_EXECUTABLE").s) ||
|
||||||
|
(q = __getenv(__envp, "_").s)) {
|
||||||
goto CopyString;
|
goto CopyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue