From 259e6fd3c43db46ddfe64eb5c0333d510fc4abf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Sun, 17 Dec 2023 13:38:50 -0500 Subject: [PATCH] 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. --- libc/calls/getprogramexecutablename.greg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libc/calls/getprogramexecutablename.greg.c b/libc/calls/getprogramexecutablename.greg.c index 1442f5f6c..70cd32a3e 100644 --- a/libc/calls/getprogramexecutablename.greg.c +++ b/libc/calls/getprogramexecutablename.greg.c @@ -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; }