summaryrefslogtreecommitdiffstats
path: root/usr.bin/env
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2008-04-17 23:17:09 +0000
committergad <gad@FreeBSD.org>2008-04-17 23:17:09 +0000
commitc5555371c3a1be660d9a3308e52fa571c46f3a42 (patch)
tree7d3f5ac4ebbc19e91b4074bcd60eefc1f6ba35db /usr.bin/env
parent986a88fe51bb6dfbe2bae613c22011289632b774 (diff)
downloadFreeBSD-src-c5555371c3a1be660d9a3308e52fa571c46f3a42.zip
FreeBSD-src-c5555371c3a1be660d9a3308e52fa571c46f3a42.tar.gz
Add the '-u name' option to the env command, which will completely unset
the given variable name (removing it from the environment, instead of just setting it to a null value). PR: bin/65649 MFC after: 2 weeks
Diffstat (limited to 'usr.bin/env')
-rw-r--r--usr.bin/env/env.126
-rw-r--r--usr.bin/env/env.c13
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);
}
OpenPOWER on IntegriCloud