diff options
-rw-r--r-- | usr.bin/env/env.1 | 26 | ||||
-rw-r--r-- | usr.bin/env/env.c | 13 |
2 files changed, 31 insertions, 8 deletions
diff --git a/usr.bin/env/env.1 b/usr.bin/env/env.1 index a1696d3..cb3980b 100644 --- a/usr.bin/env/env.1 +++ b/usr.bin/env/env.1 @@ -35,7 +35,7 @@ .\" From FreeBSD: src/usr.bin/printenv/printenv.1,v 1.17 2002/11/26 17:33:35 ru Exp .\" $FreeBSD$ .\" -.Dd June 20, 2005 +.Dd July 29, 2005 .Dt ENV 1 .Os .Sh NAME @@ -46,6 +46,7 @@ .Op Fl iv .Op Fl P Ar altpath .Op Fl S Ar string +.Op Fl u Ar name .Op Ar name Ns = Ns Ar value ... .Op Ar utility Op Ar argument ... .Sh DESCRIPTION @@ -99,6 +100,21 @@ The option recognizes some special character escape sequences and also supports environment-variable substitution, as described below. +.\" -u +.It Fl u Ar name +If the environment variable +.Ar name +is in the environment, then remove it before processing the +remaining options. +This is similar to the +.Ic unset +command in +.Xr sh 1 . +The value for +.Ar name +must not include the +.Ql = +character. .\" -v .It Fl v Print verbose information for each step of processing done by the @@ -436,12 +452,12 @@ The utility conforms to .St -p1003.1-2001 . The -.Fl P , S +.Fl P , S , u and .Fl v -options are non-standard -.Fx -extensions which may not be available on other operating systems. +options are non-standard extensions supported by +.Fx , +but which may not be available on other operating systems. .Sh HISTORY The .Nm diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c index b11a0b7..34f1e73 100644 --- a/usr.bin/env/env.c +++ b/usr.bin/env/env.c @@ -71,7 +71,7 @@ main(int argc, char **argv) altpath = NULL; want_clear = 0; - while ((ch = getopt(argc, argv, "-iP:S:v")) != -1) + while ((ch = getopt(argc, argv, "-iP:S:u:v")) != -1) switch(ch) { case '-': case 'i': @@ -87,6 +87,13 @@ main(int argc, char **argv) */ split_spaces(optarg, &optind, &argc, &argv); break; + case 'u': + if (env_verbosity) + fprintf(stderr, "#env unset:\t%s\n", optarg); + rtrn = unsetenv(optarg); + if (rtrn == -1) + err(EXIT_FAILURE, "unsetenv %s", optarg); + break; case 'v': env_verbosity++; if (env_verbosity > 1) @@ -135,7 +142,7 @@ static void usage(void) { (void)fprintf(stderr, - "usage: env [-iv] [-P utilpath] [-S string] [name=value ...]" - " [utility [argument ...]]\n"); + "usage: env [-iv] [-P utilpath] [-S string] [-u name]\n" + " [name=value ...] [utility [argument ...]]\n"); exit(1); } |