Le 15/02/2012 21:42, David Korn a écrit :
Subject: Re: Re: [ast-users] aborting a pipeline?
--------

how about using set -o pipefail ?

from man ksh :

The exit status of a pipeline is the exit status of the last command
unless the pipefail option is enabled.

pipefail
         A  pipeline  will  not complete until all compoâ
         nents of the pipeline have  completed,  and  the
         return  value will be the value of the last non-
         zero command to fail or zero if no  command  has
         failed.

w/o pipefail :



I suspect that the user who posted the query wanted the pipeline
to complete as soon as there was a failure.  With set -o pipefail,

        false | sleep 5

will take 5 seconds until the failure happens.

Maybe for pipefail, it would make sense to kill all processes in
the pipeline once any one of them fails, but that is not what
currently happens.

in the case of the user sample, the wc -l is aborted (no more input)
whenever the cat fails. its problem is to know that cat fails since
wc never fails. so, pipefail should be sufficient in that case.
also, to ignore the cat return status, -s may be used, yet also,
UUOC, the right sentence is wc -l < $file, no pipe :-)

Regards,

Cyrille Lefevre
--
mailto:[email protected]


_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to