From owner-svn-src-all@FreeBSD.ORG Sat Oct 24 21:20:04 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDC761065670; Sat, 24 Oct 2009 21:20:04 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C2ED78FC20; Sat, 24 Oct 2009 21:20:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9OLK4Ys012819; Sat, 24 Oct 2009 21:20:04 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9OLK4ZM012814; Sat, 24 Oct 2009 21:20:04 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <200910242120.n9OLK4ZM012814@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 24 Oct 2009 21:20:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198454 - in head: bin/sh tools/regression/bin/sh/expansion X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Oct 2009 21:20:05 -0000 Author: jilles Date: Sat Oct 24 21:20:04 2009 New Revision: 198454 URL: http://svn.freebsd.org/changeset/base/198454 Log: sh: Exempt $@ and $* from set -u This seems more useful and will likely be in the next POSIX standard. Also document more precisely in the man page what set -u does (note that $@, $* and $! are the only special parameters that can ever be unset, all the others are always set, although they may be empty). Added: head/tools/regression/bin/sh/expansion/set-u2.0 (contents, props changed) Modified: head/bin/sh/expand.c head/bin/sh/sh.1 Modified: head/bin/sh/expand.c ============================================================================== --- head/bin/sh/expand.c Sat Oct 24 20:57:11 2009 (r198453) +++ head/bin/sh/expand.c Sat Oct 24 21:20:04 2009 (r198454) @@ -657,7 +657,7 @@ again: /* jump here after setting a vari } varlen = 0; startloc = expdest - stackblock(); - if (!set && uflag) { + if (!set && uflag && *var != '@' && *var != '*') { switch (subtype) { case VSNORMAL: case VSTRIMLEFT: Modified: head/bin/sh/sh.1 ============================================================================== --- head/bin/sh/sh.1 Sat Oct 24 20:57:11 2009 (r198453) +++ head/bin/sh/sh.1 Sat Oct 24 21:20:04 2009 (r198454) @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd May 31, 2009 +.Dd October 24, 2009 .Dt SH 1 .Os .Sh NAME @@ -296,7 +296,10 @@ sh -T -c "trap 'exit 1' 2 ; some-blockin .Ed .It Fl u Li nounset Write a message to standard error when attempting -to expand a variable that is not set, and if the +to expand a variable, a positional parameter or +the special parameter +.Va \&! +that is not set, and if the shell is not interactive, exit immediately. .It Fl V Li vi Enable the built-in Added: head/tools/regression/bin/sh/expansion/set-u2.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/set-u2.0 Sat Oct 24 21:20:04 2009 (r198454) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +set -u +: $* $@ "$@" "$*" +set -- x +: $* $@ "$@" "$*" +shift $# +: $* $@ "$@" "$*" +set -- y +set -- +: $* $@ "$@" "$*" +exit 0