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
This commit is contained in:
parent
12b6a0f87c
commit
a414225db1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178289
26
usr.bin/env/env.1
vendored
26
usr.bin/env/env.1
vendored
@ -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
|
||||
|
13
usr.bin/env/env.c
vendored
13
usr.bin/env/env.c
vendored
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user