aboutsummaryrefslogtreecommitdiff
path: root/bin/sh/exec.c
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2014-05-31 22:25:45 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2014-05-31 22:25:45 +0000
commit2ceda70233797308c9428775ba5c761c0e0fc859 (patch)
tree6c6e46fba2b4ff696fff546c4506870b3a4b2fe2 /bin/sh/exec.c
parent6e898985fc164193d7d2ab283c549733803f1843 (diff)
downloadsrc-2ceda70233797308c9428775ba5c761c0e0fc859.tar.gz
src-2ceda70233797308c9428775ba5c761c0e0fc859.zip
sh: Simplify find_command() slightly.
Notes
Notes: svn path=/head/; revision=266932
Diffstat (limited to 'bin/sh/exec.c')
-rw-r--r--bin/sh/exec.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/bin/sh/exec.c b/bin/sh/exec.c
index e547e3136658..1b8d3c7dc22c 100644
--- a/bin/sh/exec.c
+++ b/bin/sh/exec.c
@@ -362,15 +362,13 @@ find_command(const char *name, struct cmdentry *entry, int act,
e = ENOENT;
idx = -1;
-loop:
- while ((fullname = padvance(&path, name)) != NULL) {
- stunalloc(fullname);
+ for (;(fullname = padvance(&path, name)) != NULL; stunalloc(fullname)) {
idx++;
if (pathopt) {
if (prefix("func", pathopt)) {
/* handled below */
} else {
- goto loop; /* ignore unimplemented options */
+ continue; /* ignore unimplemented options */
}
}
if (fullname[0] != '/')
@@ -378,13 +376,12 @@ loop:
if (stat(fullname, &statb) < 0) {
if (errno != ENOENT && errno != ENOTDIR)
e = errno;
- goto loop;
+ continue;
}
e = EACCES; /* if we fail, this will be the error */
if (!S_ISREG(statb.st_mode))
- goto loop;
+ continue;
if (pathopt) { /* this is a %func directory */
- stalloc(strlen(fullname) + 1);
readcmdfile(fullname);
if ((cmdp = cmdlookup(name, 0)) == NULL || cmdp->cmdtype != CMDFUNCTION)
error("%s not defined in %s", name, fullname);
@@ -405,6 +402,7 @@ loop:
#endif
TRACE(("searchexec \"%s\" returns \"%s\"\n", name, fullname));
INTOFF;
+ stunalloc(fullname);
cmdp = cmdlookup(name, 1);
if (cmdp->cmdtype == CMDFUNCTION)
cmdp = &loc_cmd;