From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 22:14:33 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.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C827CB21; Tue, 28 Oct 2014 22:14:33 +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 7F2CBEFB; Tue, 28 Oct 2014 22:14:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9SMEX0s007589; Tue, 28 Oct 2014 22:14:33 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9SMEWFD007584; Tue, 28 Oct 2014 22:14:32 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201410282214.s9SMEWFD007584@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Tue, 28 Oct 2014 22:14:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273802 - in head/bin/sh: . tests/parameters 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-1 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: Tue, 28 Oct 2014 22:14:33 -0000 Author: jilles Date: Tue Oct 28 22:14:31 2014 New Revision: 273802 URL: https://svnweb.freebsd.org/changeset/base/273802 Log: Treat IFS separators in "$*" as quoted. This makes a difference if IFS starts with *, ?, [ or a CTL* byte. Added: head/bin/sh/tests/parameters/positional6.0 (contents, props changed) head/bin/sh/tests/parameters/positional7.0 (contents, props changed) Modified: head/bin/sh/expand.c head/bin/sh/tests/parameters/Makefile Modified: head/bin/sh/expand.c ============================================================================== --- head/bin/sh/expand.c Tue Oct 28 21:06:04 2014 (r273801) +++ head/bin/sh/expand.c Tue Oct 28 22:14:31 2014 (r273802) @@ -878,7 +878,7 @@ varvalue(const char *name, int quoted, i int num; char *p; int i; - char sep; + char sep[2]; char **ap; switch (*name) { @@ -912,15 +912,18 @@ varvalue(const char *name, int quoted, i /* FALLTHROUGH */ case '*': if (ifsset()) - sep = ifsval()[0]; + sep[0] = ifsval()[0]; else - sep = ' '; + sep[0] = ' '; + sep[1] = '\0'; for (ap = shellparam.p ; (p = *ap++) != NULL ; ) { strtodest(p, flag, subtype, quoted); if (!*ap) break; - if (sep || (flag & EXP_FULL && !quoted && **ap != '\0')) - STPUTC(sep, expdest); + if (sep[0]) + strtodest(sep, flag, subtype, quoted); + else if (flag & EXP_FULL && !quoted && **ap != '\0') + STPUTC('\0', expdest); } return; default: Modified: head/bin/sh/tests/parameters/Makefile ============================================================================== --- head/bin/sh/tests/parameters/Makefile Tue Oct 28 21:06:04 2014 (r273801) +++ head/bin/sh/tests/parameters/Makefile Tue Oct 28 22:14:31 2014 (r273802) @@ -18,6 +18,8 @@ FILES+= positional2.0 FILES+= positional3.0 FILES+= positional4.0 FILES+= positional5.0 +FILES+= positional6.0 +FILES+= positional7.0 FILES+= pwd1.0 FILES+= pwd2.0 Added: head/bin/sh/tests/parameters/positional6.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/parameters/positional6.0 Tue Oct 28 22:14:31 2014 (r273802) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +IFS=? +set p r +v=pqrs +r=${v#"$*"} +[ "$r" = pqrs ] Added: head/bin/sh/tests/parameters/positional7.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/parameters/positional7.0 Tue Oct 28 22:14:31 2014 (r273802) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +set -- / '' +IFS=* +set -- "$*" +IFS=: +args="$*" +[ "$#:$args" = "1:/*" ]