literally means no path search

Unlike loader.c, we need AccessCommand to handle the `.ape` indirection.
So FindCommand stays.
This commit is contained in:
Jōshin 2024-01-07 02:48:26 -05:00
parent 2e3668b430
commit 57435d0283
No known key found for this signature in database

View file

@ -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 */