Skip to content

Commit

Permalink
Only need one "no such file or directory" error message from exec.
Browse files Browse the repository at this point in the history
  • Loading branch information
landley committed Sep 13, 2023
1 parent e92d3ea commit 5ac5575
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions toys/pending/sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -2707,14 +2707,15 @@ static void sh_exec(char **argv)
{
char *pp = getvar("PATH" ? : _PATH_DEFPATH), *ss = TT.isexec ? : *argv,
**sss = 0, **oldenv = environ, **argv2;
int norecurse = CFG_TOYBOX_NORECURSE || !toys.stacktop || TT.isexec;
struct string_list *sl = 0;
struct toy_list *tl = 0;

if (getpid() != TT.pid) signal(SIGINT, SIG_DFL); // TODO: restore all?
errno = ENOENT;
if (strchr(ss, '/')) {
if (access(ss, X_OK)) ss = 0;
} else if (CFG_TOYBOX_NORECURSE || !toys.stacktop || TT.isexec || !(tl = toy_find(ss)))
} else if (norecurse || !(tl = toy_find(ss)))
for (sl = find_in_path(pp, ss); sl || (ss = 0); free(llist_pop(&sl)))
if (!access(ss = sl->str, X_OK)) break;

Expand Down Expand Up @@ -4599,7 +4600,6 @@ void exec_main(void)
sh_exec(toys.optargs);

// report error (usually ENOENT) and return
perror_msg("%s", TT.isexec);
if (*toys.optargs != TT.isexec) free(*toys.optargs);
TT.isexec = 0;
toys.exitval = 127;
Expand Down

0 comments on commit 5ac5575

Please sign in to comment.