Use new ID scheme.
Fix env(1)'s exit status to conform with SUSv3. Submitted by: Tim Robbins <tim@robbins.dropbear.id.au> MFC after: 2 weeks
This commit is contained in:
parent
014e78d18c
commit
603460a71c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91004
12
usr.bin/env/env.c
vendored
12
usr.bin/env/env.c
vendored
@ -31,17 +31,23 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if 0
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char copyright[] =
|
static char copyright[] =
|
||||||
"@(#) Copyright (c) 1988, 1993, 1994\n\
|
"@(#) Copyright (c) 1988, 1993, 1994\n\
|
||||||
The Regents of the University of California. All rights reserved.\n";
|
The Regents of the University of California. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char sccsid[] = "@(#)env.c 8.3 (Berkeley) 4/2/94";
|
static char sccsid[] = "@(#)env.c 8.3 (Berkeley) 4/2/94";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -75,7 +81,7 @@ main(argc, argv)
|
|||||||
(void)setenv(*argv, ++p, 1);
|
(void)setenv(*argv, ++p, 1);
|
||||||
if (*argv) {
|
if (*argv) {
|
||||||
execvp(*argv, argv);
|
execvp(*argv, argv);
|
||||||
err(1, "%s", *argv);
|
err(errno == ENOENT ? 127 : 126, "%s", *argv);
|
||||||
}
|
}
|
||||||
for (ep = environ; *ep; ep++)
|
for (ep = environ; *ep; ep++)
|
||||||
(void)printf("%s\n", *ep);
|
(void)printf("%s\n", *ep);
|
||||||
|
@ -57,12 +57,6 @@ If
|
|||||||
is specified, only
|
is specified, only
|
||||||
its value is printed.
|
its value is printed.
|
||||||
.Pp
|
.Pp
|
||||||
If a
|
|
||||||
.Ar name
|
|
||||||
is specified and it is not defined in the environment,
|
|
||||||
.Nm
|
|
||||||
returns exit status 1, else it returns status 0.
|
|
||||||
.Pp
|
|
||||||
Some shells may provide a builtin
|
Some shells may provide a builtin
|
||||||
.Nm
|
.Nm
|
||||||
command which is similar or identical to this utility.
|
command which is similar or identical to this utility.
|
||||||
@ -122,11 +116,26 @@ this way also allows one to reference
|
|||||||
.Pa foo
|
.Pa foo
|
||||||
without the path,
|
without the path,
|
||||||
as well as set up the environment as desired.
|
as well as set up the environment as desired.
|
||||||
|
.Sh DIAGNOSTICS
|
||||||
|
.Ex -std printenv
|
||||||
|
.Pp
|
||||||
|
.Ex -std env
|
||||||
|
An exit status of 126 indicates
|
||||||
|
.Ar command
|
||||||
|
was found, but could not be executed.
|
||||||
|
An exit status of 127 indicates
|
||||||
|
.Ar command
|
||||||
|
could not be found.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr csh 1 ,
|
.Xr csh 1 ,
|
||||||
.Xr sh 1 ,
|
.Xr sh 1 ,
|
||||||
.Xr execvp 3 ,
|
.Xr execvp 3 ,
|
||||||
.Xr environ 7
|
.Xr environ 7
|
||||||
|
.Sh STANDARDS
|
||||||
|
The
|
||||||
|
.Nm env
|
||||||
|
utility conforms to
|
||||||
|
.St -p1003.1-2001 .
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
|
Loading…
Reference in New Issue
Block a user