-.\" $OpenBSD: env.1,v 1.20 2015/01/12 21:42:53 deraadt Exp $
+.\" $OpenBSD: env.1,v 1.21 2024/07/28 10:08:44 kn Exp $
.\" Copyright (c) 1980, 1990 The Regents of the University of California.
.\" All rights reserved.
.\"
.\"
.\" from: @(#)printenv.1 6.7 (Berkeley) 7/28/91
.\"
-.Dd $Mdocdate: January 12 2015 $
+.Dd $Mdocdate: July 28 2024 $
.Dt ENV 1
.Os
.Sh NAME
.Sh SYNOPSIS
.Nm env
.Op Fl i
+.Op Fl u Ar name
.Oo
.Ar name Ns = Ns Ar value ...
.Oc
Causes
.Nm
to completely ignore the environment it inherits.
+.It Fl u Ar name
+Remove
+.Ar name
+from the environment.
.El
.Pp
If no
utility is compliant with the
.St -p1003.1-2008
specification.
+The flag
+.Op Fl u
+is an extension to that specification.
.Pp
The historic
.Fl
-/* $OpenBSD: env.c,v 1.17 2016/10/28 07:22:59 schwarze Exp $ */
+/* $OpenBSD: env.c,v 1.18 2024/07/28 10:08:44 kn Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
if (pledge("stdio exec", NULL) == -1)
err(1, "pledge");
- while ((ch = getopt(argc, argv, "i-")) != -1)
+ while ((ch = getopt(argc, argv, "-iu:")) != -1)
switch(ch) {
case '-': /* obsolete */
case 'i':
if ((environ = calloc(1, sizeof(char *))) == NULL)
err(126, "calloc");
break;
+ case 'u':
+ if (unsetenv(optarg) == -1)
+ err(126, "unsetenv");
+ break;
default:
usage();
}
{
extern char *__progname;
- (void)fprintf(stderr, "usage: %s [-i] [name=value ...] "
+ (void)fprintf(stderr, "usage: %s [-i] [-u name] [name=value ...] "
"[utility [argument ...]]\n", __progname);
exit(1);
}