diff options
author | tjr <tjr@FreeBSD.org> | 2002-05-19 08:30:16 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-05-19 08:30:16 +0000 |
commit | b19972e69908fd7043a6a2bfddea31972da28d1b (patch) | |
tree | 92887cc19a59f7c10c33e8caa74a3055004cb281 /bin/sh/expand.c | |
parent | 665a4c992b819cc10c913d3822e272fa43154e35 (diff) | |
download | FreeBSD-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/sh/expand.c')
-rw-r--r-- | bin/sh/expand.c | 11 |
1 files changed, 11 insertions, 0 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) { |