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

Re: PRINT_EXIT_VALUE: Suppress for if/while conditions



On 2015-08-15 03:20:35 +0200, Mikael Magnusson wrote:
> Seeing the exit value of each zgrep invocation seems to be within the
> scope of the option. If you find it annoying, maybe you shouldn't have
> it set?

I have it set because I like it for individual commands.

> For example if you did
> 
> for i in file1 file2; do
>   veryimportanttask $i
> done
> 
> you would surely want to see if any of the invocations failed.

But you don't know which one:

$ for i in 1 2; do /bin/false $i; done
zsh: exit 1     /bin/false $i
zsh: exit 1     /bin/false $i

One could write

  veryimportanttask $i || echo error for $i

in such a case, which is more informative.

With my example above, without PRINT_EXIT_VALUE:

$ for i in 1 2; do /bin/false $i || echo error for $i; done
error for 1
error for 2

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



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