From owner-svn-src-head@freebsd.org Sun Apr 2 12:37:44 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 731EFD29440; Sun, 2 Apr 2017 12:37:44 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 4010E9CE; Sun, 2 Apr 2017 12:37:44 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v32Cbhqj082872; Sun, 2 Apr 2017 12:37:43 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v32CbhUV082871; Sun, 2 Apr 2017 12:37:43 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201704021237.v32CbhUV082871@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 2 Apr 2017 12:37:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316414 - 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.23 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: Sun, 02 Apr 2017 12:37:44 -0000 Author: jilles Date: Sun Apr 2 12:37:43 2017 New Revision: 316414 URL: https://svnweb.freebsd.org/changeset/base/316414 Log: sh: Don't scan word twice in ${param+-word}. There is no longer a case where argbackq has already been advanced but the string pointer needs to be advanced. Modified: head/bin/sh/expand.c Modified: head/bin/sh/expand.c ============================================================================== --- head/bin/sh/expand.c Sun Apr 2 11:36:25 2017 (r316413) +++ head/bin/sh/expand.c Sun Apr 2 12:37:43 2017 (r316414) @@ -753,15 +753,14 @@ again: /* jump here after setting a vari break; case VSNORMAL: - break; + return p; case VSPLUS: case VSMINUS: if (!set) { - argstr(p, argbackq, + return argstr(p, argbackq, flag | (flag & EXP_SPLIT ? EXP_SPLIT_LIT : 0) | (varflags & VSQUOTE ? EXP_LIT_QUOTED : 0), dst); - break; } break; @@ -769,10 +768,8 @@ again: /* jump here after setting a vari case VSTRIMLEFTMAX: case VSTRIMRIGHT: case VSTRIMRIGHTMAX: - if (!set) { - set = 1; + if (!set) break; - } /* * Terminate the string and start recording the pattern * right after it @@ -805,15 +802,14 @@ again: /* jump here after setting a vari abort(); } - if (subtype != VSNORMAL) { /* skip to end of alternative */ + { /* skip to end of alternative */ int nesting = 1; for (;;) { if ((c = *p++) == CTLESC) p++; - else if (c == CTLBACKQ || c == (CTLBACKQ|CTLQUOTE)) { - if (set) - *argbackq = (*argbackq)->next; - } else if (c == CTLVAR) { + else if (c == CTLBACKQ || c == (CTLBACKQ|CTLQUOTE)) + *argbackq = (*argbackq)->next; + else if (c == CTLVAR) { if ((*p++ & VSTYPE) != VSNORMAL) nesting++; } else if (c == CTLENDVAR) {