Implement the -u (-o nounset) option, which gives an error message if

an unset variable is expanded.

Obtained from:	NetBSD (bjh21, christos)
This commit is contained in:
Tim J. Robbins 2002-05-19 08:30:16 +00:00
parent 84b3ce6811
commit 1b5a48ff88
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=96939
2 changed files with 11 additions and 1 deletions

View File

@ -657,6 +657,17 @@ evalvar(char *p, int flag)
}
varlen = 0;
startloc = expdest - stackblock();
if (!set && uflag) {
switch (subtype) {
case VSNORMAL:
case VSTRIMLEFT:
case VSTRIMLEFTMAX:
case VSTRIMRIGHT:
case VSTRIMRIGHTMAX:
case VSLENGTH:
error("%.*s: parameter not set", p - var - 1, var);
}
}
if (set && subtype != VSPLUS) {
/* insert the value of the variable */
if (special) {

View File

@ -264,7 +264,6 @@ sh -T -c "trap 'exit 1' 2 ; some-blocking-program"
Write a message to standard error when attempting
to expand a variable that is not set, and if the
shell is not interactive, exit immediately.
(UNIMPLEMENTED)
.It Fl V Li vi
Enable the builtin
.Xr vi 1