help-bash
[Top][All Lists]
Advanced

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

Re: Shopt to change default connector to '&&'


From: Lawrence Velázquez
Subject: Re: Shopt to change default connector to '&&'
Date: Sat, 11 Mar 2023 11:59:32 -0500
User-agent: Cyrus-JMAP/3.9.0-alpha0-206-g57c8fdedf8-fm-20230227.001-g57c8fded

On Sat, Mar 11, 2023, at 3:43 AM, Hugues Morisset wrote:
> Thanks a lots for the instructions, I'll fix the patch when I get some time.
> An very simple example you can try is
>
> foo() {
>     false
>     echo foo
> }
> bar() {
>     echo bar
> }
> foo || bar
>
> which print foo but with default_connector_and_and on it will print bar.

Okay, I didn't notice a difference at first because I tested with
top-level commands, which don't seem to be affected at all.  This
is supposed to be less quirky than "set -e"?

        % cat /tmp/testcase1.bash
        shopt -s default_connector_and_and
        {
            false
            echo foo
        }
        % ./bash /tmp/testcase1.bash; echo "$?"
        1

        % cat /tmp/testcase2.bash
        shopt -s default_connector_and_and
        false
        echo foo
        % ./bash /tmp/testcase2.bash; echo "$?"
        foo
        0

-- 
vq



reply via email to

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