I find this a fairly useful method in bash, if not perfect.

function pipe_status()
{
    local -a pipestatus=( $...@} )
    for ((p=0;p<${#pipestat...@]};p++))
    do
        if [[ ${pipestatus[${p}]} -ne 0 ]]
        then
            echo "failure in pipe index ${p} (${pipestatus[${p}]})" >&2
            return ${pipestatus[${p}]}
        fi
    done
    return 0
}
#---------------------------------------------------------------------
do | a | really | long | pipe
pipe_status ${pipestat...@]} || handle_error ${?}


I don't use hush though, so no idea if this will work in that shell or
not.
-C

On Tue, 2010-11-09 at 01:40 -0500, Rob Landley wrote:
> Or any set -o for that matter.  But pipefail's one that's really hard to work 
> around if you haven't got it...
> 
> Rob


_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to