From d73e77d0796f6ad91b6a02478939cce77dd44377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Sun, 7 Jan 2024 01:25:39 -0500 Subject: [PATCH] execfn is _ or else prog --- ape/ape-m1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ape/ape-m1.c b/ape/ape-m1.c index 888dd1898..6e872971f 100644 --- a/ape/ape-m1.c +++ b/ape/ape-m1.c @@ -954,7 +954,7 @@ int main(int argc, char **argv, char **envp) { M->lib.dlerror = dlerror; /* getenv("_") is close enough to at_execfn */ - execfn = argc > 0 ? argv[0] : 0; + execfn = 0; for (i = 0; envp[i]; ++i) { if (envp[i][0] == '_' && envp[i][1] == '=') { execfn = envp[i] + 2; @@ -993,9 +993,6 @@ int main(int argc, char **argv, char **envp) { ln -sf /usr/local/bin/ape /opt/cosmos/bin/bash.ape and then use #!/opt/cosmos/bin/bash.ape instead. */ M->ps.literally = 0; - if (!execfn) { - execfn = prog; - } argc = sp[0]; argv = (char **)(sp + 1); } else if ((M->ps.literally = argc >= 3 && !StrCmp(argv[1], "-"))) { @@ -1019,6 +1016,9 @@ int main(int argc, char **argv, char **envp) { argc = sp[1] = sp[0] - 1; argv = (char **)((sp += 1) + 1); } + if (!execfn) { + execfn = prog; + } /* allocate ephemeral memory for reading file */ n = sizeof(union ElfEhdrBuf);