On Thu, Jul 22, 2010 at 05:38:29PM -0400, Daniel Dickman wrote:
> 
> I think the man page is bit confusing. Note that I sent jmc@ the patch 
> below for the man page to try to clear things up a bit there as well. The 
> main point is that 1-125 is an error range reserved for any errors that 
> happens within env itself.
> 
> However the entire range of exit codes is _REUSED_ in the case that 
> utility was (1) specified, (2) successfully located and (3) succesfully 
> invoked. In that case, the return code from env is whatever the underlying 
> utility returns.
> 
> But as I said, any errors in env itself (as opposed to the underlying 
> utility) should be in the range 1-125 (at least that's my reading of 
> posix).
> 

i don;t understand this, but then i don;t know *exactly* what the code
does. but i don;t see why you find that section confusing.

why do you say that 1-125 is reserved by env and that env is reusing
them? as documented, you just get the return value from the utility.

> In particular, think about the case when utility is not specified at all.
> I don't think it would make sense to return 126 in that case.

as documented, in that case it returns 0.

> 
> Unfortunately, the exit codes are already ambiguous. What happens when 1 
> is returned? Was this from the underlying utility that exited with return 
> code 1 or did I specify something incorrectly on the command-line? (Note 
> my addition to the BUGS section in my patch below).
> 
>   # cat ./test.sh
>   #!/bin/sh
>   exit 1
>   # env ./test.sh
>   # echo $?
>   1

utility (test.sh) returns 1

>   # env -t
>   env: unknown option -- t
>   usage: env [-i] [name=value ...] [utility [argument ...]]
>   # echo $?
>   1
> 

env returns 1

> In any case, patch to env.1 man page follows as well in case you have some 
> feedback there as well.
> 

i think we should understand why you find the text in env confusing
first, then see if there really is a problem.

jmc

> 
> Index: env.1
> ===================================================================
> RCS file: /usr/cvs/src/usr.bin/env/env.1,v
> retrieving revision 1.17
> diff -u -r1.17 env.1
> --- env.1     8 Feb 2009 17:15:09 -0000       1.17
> +++ env.1     22 Jul 2010 20:30:20 -0000
> @@ -76,27 +76,25 @@
>  of the variables in the environment, with one
>  .Ar name Ns = Ns Ar value
>  pair per line.
> -.Sh DIAGNOSTICS
> +.Pp
> +If
> +.Ar utility
> +is specified and was successfully invoked, the exit code returned by
>  .Nm
> -exits with one of the following values:
> -.Bl -tag -width Ds
> +is the exit code of
> +.Ar utility .
> +.Pp
> +Otherwise, the
> +.Nm
> +utility exits with one of the following values:
> +.Bl -tag -width Ds -compact -offset indent
>  .It 0
> -.Ar utility
> -was invoked and completed successfully.
> -In this case the exit code is returned by the utility itself, not
> -.Nm .
> -If no utility was specified, then
> -.Nm
> -completed successfully and returned the exit code itself.
> -.It 1
> -An invalid command line option was passed to
> -.Nm .
> +.Nm
> +completed successfully.
>  .It 1\(en125
> -.Ar utility
> -was invoked but failed in some way;
> -see its manual page for more information.
> -In this case the exit code is returned by the utility itself, not
> -.Nm .
> +An error occurred in the
> +.Nm
> +utility.
>  .It 126
>  .Ar utility
>  was found but could not be invoked.
> @@ -123,3 +121,8 @@
>  .Pq Sq =
>  signs in their
>  names, for obvious reasons.
> +.Pp
> +There is no way to determine whether an exit code was returned by
> +.Nm
> +or by the underlying
> +.Ar utility .

Reply via email to