From owner-svn-src-head@FreeBSD.ORG Sat May 31 22:25:46 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 99CE1702; Sat, 31 May 2014 22:25:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 871E82382; Sat, 31 May 2014 22:25:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4VMPkB9062417; Sat, 31 May 2014 22:25:46 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4VMPk8t062416; Sat, 31 May 2014 22:25:46 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201405312225.s4VMPk8t062416@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 31 May 2014 22:25:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266932 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 May 2014 22:25:46 -0000 Author: jilles Date: Sat May 31 22:25:45 2014 New Revision: 266932 URL: http://svnweb.freebsd.org/changeset/base/266932 Log: sh: Simplify find_command() slightly. Modified: head/bin/sh/exec.c Modified: head/bin/sh/exec.c ============================================================================== --- head/bin/sh/exec.c Sat May 31 21:12:14 2014 (r266931) +++ head/bin/sh/exec.c Sat May 31 22:25:45 2014 (r266932) @@ -362,15 +362,13 @@ find_command(const char *name, struct cm 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;