nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] folder -nocreate +/this/does/not/exist

2016-08-29 10:09:04
Hi Norm,

Confession: I have never fixed this problem:

     false|true

Then true is run and the command does not return an error value.

Yes, the traditional exit status of a pipe is that of its last command.
bash has a pipefail shell option.

    The return status of a pipeline is the exit status of the last
    command, unless the pipefail option is enabled.  If pipefail is
    enabled, the pipeline's return status is the value of the last
    (rightmost) command to exit with a non-zero status, or zero if all
    commands exit successfully.  If the reserved word !  precedes a
    pipeline, the exit status of that pipeline is the logical negation
    of the exit status as described above.  The shell waits for all
    commands in the pipeline to terminate before returning a value.

Thus

    $ bash -c 'false | true; echo $?; set -o pipefail; false | true; echo $?'
    0
    1
    $

My bash scripts start

    set -eEu -o pipefail
    shopt -s failglob
    trap 'echo ${0##*/}: line $LINENO: unexpected exit: $? >&2' ERR

    progname=${0##*/}

-- 
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>