summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-05-19 08:30:16 +0000
committertjr <tjr@FreeBSD.org>2002-05-19 08:30:16 +0000
commitb19972e69908fd7043a6a2bfddea31972da28d1b (patch)
tree92887cc19a59f7c10c33e8caa74a3055004cb281 /bin
parent665a4c992b819cc10c913d3822e272fa43154e35 (diff)
downloadFreeBSD-src-b19972e69908fd7043a6a2bfddea31972da28d1b.zip
FreeBSD-src-b19972e69908fd7043a6a2bfddea31972da28d1b.tar.gz
Implement the -u (-o nounset) option, which gives an error message if
an unset variable is expanded. Obtained from: NetBSD (bjh21, christos)
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/expand.c11
-rw-r--r--bin/sh/sh.11
2 files changed, 11 insertions, 1 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index f6a0a09..46214b9 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -657,6 +657,17 @@ again: /* jump here after setting a variable with ${var=text} */
}
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) {
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index e9f5f08..54e4465 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -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
OpenPOWER on IntegriCloud