From owner-freebsd-standards Tue Feb 12 19:16:31 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (020.c.001.mel.iprimus.net.au [203.134.131.20]) by hub.freebsd.org (Postfix) with ESMTP id 5D33537B417 for ; Tue, 12 Feb 2002 19:16:25 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g1D2xZj04306 for freebsd-standards@FreeBSD.ORG; Wed, 13 Feb 2002 13:59:35 +1100 (EST) (envelope-from tim) Date: Wed, 13 Feb 2002 13:59:35 +1100 From: Tim Robbins To: freebsd-standards@FreeBSD.ORG Subject: env(1) and P1003.2-1992 conformance Message-ID: <20020213135934.A4228@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Here is a patch that corrects the exit status of the env utility to make it compatible with P1003.2-1992. OpenBSD and NetBSD exit with the right status (see NetBSD env.c revision 1.2 from 1993), FreeBSD does not. This really is a trivial change. Tim Index: env/env.c =================================================================== RCS file: /home/ncvs/src/usr.bin/env/env.c,v retrieving revision 1.5 diff -u -r1.5 env.c --- env/env.c 1999/08/27 08:59:31 1.5 +++ env/env.c 2002/02/13 02:50:49 @@ -42,6 +42,7 @@ #endif /* not lint */ #include +#include #include #include #include @@ -75,7 +76,7 @@ (void)setenv(*argv, ++p, 1); if (*argv) { execvp(*argv, argv); - err(1, "%s", *argv); + err(errno == ENOENT ? 127 : 126, "%s", *argv); } for (ep = environ; *ep; ep++) (void)printf("%s\n", *ep); Index: printenv/printenv.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/printenv/printenv.1,v retrieving revision 1.11 diff -u -r1.11 printenv.1 --- printenv/printenv.1 2001/07/05 06:35:03 1.11 +++ printenv/printenv.1 2002/02/13 02:51:01 @@ -57,12 +57,6 @@ is specified, only its value is printed. .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 .Nm command which is similar or identical to this utility. @@ -122,11 +116,24 @@ .Pa foo without the path, as well as set up the environment as desired. +.Sh DIAGNOSTICS +.Ex -std printenv +.Pp +.Ex -std env +The +.Nm env +utility exits 126 if the requested utility was found but +could not be executed and 127 if the utility could not be found. .Sh SEE ALSO .Xr csh 1 , .Xr sh 1 , .Xr execvp 3 , .Xr environ 7 +.Sh STANDARDS +The +.Nm env +utility is expected to be compatible with +.St -p1003.2-92 . .Sh HISTORY The .Nm To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message