[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] && precedence
From: |
Matthew Cengia |
Subject: |
Re: [Help-bash] && precedence |
Date: |
Wed, 9 Aug 2017 22:01:21 +1000 |
Oh, I misread your question; you have the tests in the reverse order. I'm
not 100% sure about this one; sorry.
On Wed, Aug 9, 2017 at 10:00 PM, Matthew Cengia <address@hidden> wrote:
> According to 'greybot' from #bash on Freenode:
>
> > foo && bar || baz is not equivalent to 'if foo; then bar; else baz; fi'.
> In the former case, baz will happen if *either* foo *or* bar return false.
> In the latter case, baz will only trigger if foo returns false, regardless
> of the exit code for bar. See http://mywiki.wooledge.org/BashPitfalls
>
> On Wed, Aug 9, 2017 at 9:35 PM, Russell Shaw <address@hidden>
> wrote:
>
>> Hi,
>> When i do:
>>
>> true || echo hi
>>
>> there is no "hi" as expected
>>
>>
>> when i do:
>>
>> true || true && echo hi
>>
>> i get "hi" echoed. Why does "true && echo hi" get evaluated?
>>
>>
>
>
> --
> Regards,
> Matthew Cengia
>
--
Regards,
Matthew Cengia