From 57435d0283d96e599d9124270e8f119f4a24b0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Sun, 7 Jan 2024 02:48:26 -0500 Subject: [PATCH] literally means no path search Unlike loader.c, we need AccessCommand to handle the `.ape` indirection. So FindCommand stays. --- ape/ape-m1.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ape/ape-m1.c b/ape/ape-m1.c index 61c072f8c..1252a11cd 100644 --- a/ape/ape-m1.c +++ b/ape/ape-m1.c @@ -361,12 +361,8 @@ static char FindCommand(struct PathSearcher *ps) { ps->path[0] = 0; /* paths are always 100% taken literally when a slash exists - $ ape foo/bar.com arg1 arg2 */ - if (memchr(ps->name, '/', ps->namelen)) { - return AccessCommand(ps, 0); - } - - /* we don't run files in the current directory + $ ape foo/bar.com arg1 arg2 + we don't run files in the current directory $ ape foo.com arg1 arg2 unless $PATH has an empty string entry, e.g. $ expert PATH=":/bin" @@ -374,8 +370,8 @@ static char FindCommand(struct PathSearcher *ps) { however we will execute this $ ape - foo.com foo.com arg1 arg2 because cosmo's execve needs it */ - if (ps->literally && AccessCommand(ps, 0)) { - return 1; + if (ps->literally || memchr(ps->name, '/', ps->namelen)) { + return AccessCommand(ps, 0); } /* otherwise search for name on $PATH */