[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Ralph Corderoy
Subject: Re: [Nmh-workers] folder -nocreate +/this/does/not/exist
Date: Mon, 29 Aug 2016 16:08:26 +0100

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.


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

My bash scripts start

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


Cheers, Ralph.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]