svn commit: r215066 - in stable/8: bin/sh
tools/regression/bin/sh/expansion
Jilles Tjoelker
jilles at FreeBSD.org
Tue Nov 9 22:32:12 UTC 2010
Author: jilles
Date: Tue Nov 9 22:32:11 2010
New Revision: 215066
URL: http://svn.freebsd.org/changeset/base/215066
Log:
MFC r198454: 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:
stable/8/tools/regression/bin/sh/expansion/set-u2.0
- copied unchanged from r198454, head/tools/regression/bin/sh/expansion/set-u2.0
Modified:
stable/8/bin/sh/expand.c
stable/8/bin/sh/sh.1
Directory Properties:
stable/8/bin/sh/ (props changed)
stable/8/tools/regression/bin/sh/ (props changed)
Modified: stable/8/bin/sh/expand.c
==============================================================================
--- stable/8/bin/sh/expand.c Tue Nov 9 22:32:09 2010 (r215065)
+++ stable/8/bin/sh/expand.c Tue Nov 9 22:32:11 2010 (r215066)
@@ -670,7 +670,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: stable/8/bin/sh/sh.1
==============================================================================
--- stable/8/bin/sh/sh.1 Tue Nov 9 22:32:09 2010 (r215065)
+++ stable/8/bin/sh/sh.1 Tue Nov 9 22:32:11 2010 (r215066)
@@ -311,7 +311,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
Copied: stable/8/tools/regression/bin/sh/expansion/set-u2.0 (from r198454, head/tools/regression/bin/sh/expansion/set-u2.0)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ stable/8/tools/regression/bin/sh/expansion/set-u2.0 Tue Nov 9 22:32:11 2010 (r215066, copy of r198454, head/tools/regression/bin/sh/expansion/set-u2.0)
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+set -u
+: $* $@ "$@" "$*"
+set -- x
+: $* $@ "$@" "$*"
+shift $#
+: $* $@ "$@" "$*"
+set -- y
+set --
+: $* $@ "$@" "$*"
+exit 0
More information about the svn-src-stable-8
mailing list