Support COSMOPOLITAN_PROGRAM_EXECUTABLE

The loader implementing it was never minted, so it seems reasonable not
to keep support for it indefinitely. But it seems impolite to break the
prerelease loaders people may have been using between releases.
This commit is contained in:
Jōshin 2023-12-17 13:38:50 -05:00
parent e582b1c286
commit 259e6fd3c4
No known key found for this signature in database

View file

@ -185,9 +185,11 @@ static inline void InitProgramExecutableNameImpl(void) {
goto UseEmpty;
}
// Try what the loader supplied first. Fall back to argv[0],
// try what the loader supplied first. fall back to argv[0],
// then argv[0].com, then $_, then $_.com.
if (TryPath(__program_executable_name, 0) || TryPath(__argv[0], 1) ||
/* TODO(mrdomino): remove after next loader mint */
TryPath(__getenv(__envp, "COSMOPOLITAN_PROGRAM_EXECUTABLE").s, 0) ||
TryPath(__getenv(__envp, "_").s, 1)) {
goto UseBuf;
}