Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PRINT_EXIT_VALUE problems



On 2011-12-28 11:28:35 -0800, Bart Schaefer wrote:
> I've been thinking about this a bit more.
> 
> Consider the case of a pipeline -- here's a silly example:
> 
> torch% return 3 | return 2 | return 1 | true
> zsh: exit 3     return 3 | 
> zsh: exit 2     return 2 | 
> zsh: exit 1     return 1
> torch% 
> 
> Now consider:
> 
> torch% return 3 | return 2 | return 1 || true
> 
> If we followed your suggestion above, we should suppress printing the
> exit values of every stage of the pipeline.

I don't think so, since the exit values of "return 3" and "return 2"
don't affect the exit value of the pipeline. The "|| ..." should
mean that one isn't interested in the exit value of the pipeline
and what caused this exit value (i.e. "return 1").

>  Is that really desirable?
> 
> What about
> 
> torch% { (return 3); (return 2); return 1 } || true
> 
> Which exit values should be printed there?

(return 3) and (return 2) do not affect the tested value for ||, thus
there exit values should be printed. The tested value for || is the
exit value of "return 1", thus this one should not be printed.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author