From owner-svn-src-head@FreeBSD.ORG Sat Aug 24 20:06:00 2013 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 ESMTP id DA9D2DD5; Sat, 24 Aug 2013 20:06:00 +0000 (UTC) (envelope-from jilles@FreeBSD.org) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C733C20B8; Sat, 24 Aug 2013 20:06:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7OK60l9036250; Sat, 24 Aug 2013 20:06:00 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7OK60e0036247; Sat, 24 Aug 2013 20:06:00 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201308242006.r7OK60e0036247@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 24 Aug 2013 20:06:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254806 - in head: bin/sh tools/regression/bin/sh/expansion 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.14 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, 24 Aug 2013 20:06:00 -0000 Author: jilles Date: Sat Aug 24 20:06:00 2013 New Revision: 254806 URL: http://svnweb.freebsd.org/changeset/base/254806 Log: sh: Reject ++ and -- in arithmetic. POSIX does not require ++ and -- in arithmetic. It is probably more useful to reject them than to treat ++x and --x as x silently. Note that the behaviour of increment and decrement can be obtained via (x+=1), ((x+=1)-1), (x-=1) and ((x-=1)+1). PR: bin/176444 Added: head/tools/regression/bin/sh/expansion/arith13.0 (contents, props changed) Modified: head/bin/sh/arith_yylex.c Modified: head/bin/sh/arith_yylex.c ============================================================================== --- head/bin/sh/arith_yylex.c Sat Aug 24 19:58:36 2013 (r254805) +++ head/bin/sh/arith_yylex.c Sat Aug 24 20:06:00 2013 (r254806) @@ -218,9 +218,13 @@ checkeqcur: value += ARITH_REM - '%'; goto checkeq; case '+': + if (buf[1] == '+') + return ARITH_BAD; value += ARITH_ADD - '+'; goto checkeq; case '-': + if (buf[1] == '-') + return ARITH_BAD; value += ARITH_SUB - '-'; goto checkeq; case '~': Added: head/tools/regression/bin/sh/expansion/arith13.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/arith13.0 Sat Aug 24 20:06:00 2013 (r254806) @@ -0,0 +1,6 @@ +# $FreeBSD$ +# Pre-increment and pre-decrement in arithmetic expansion are not in POSIX. +# Require either an error or a correct implementation. + +! (eval 'x=4; [ $((++x)) != 5 ] || [ $x != 5 ]') 2>/dev/null && +! (eval 'x=2; [ $((--x)) != 1 ] || [ $x != 1 ]') 2>/dev/null