Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: unintuitive bracketing with return value
On Tue, Oct 18, 2022, at 1:57 PM, Ray Andrews wrote:
> On 2022-10-18 07:57, Eric Cook wrote:
>>
>> https://mywiki.wooledge.org/BashPitfalls#pf22
>>
> Very well written!  What breaks my intuition tho is the brackets.  
> Otherwise I quite understand that the last exit value is the active 
> one.  I'm expecting the brackets to 'contain' the rv of any commands 
> within the brackets.  But no, the left > right rule applies and the 
> brackets don't make any difference.
I don't understand why you keep saying this.  Without the braces
your command would be completely different.  This:
    [ "${${1}##*[*?]*}" ] &&
    echo "no wildcards"; printenv "$1" ||
    echo wildcards present
is equivalent to this:
    [ "${${1}##*[*?]*}" ] && echo "no wildcards"
    printenv "$1" || echo wildcards present
which is not at all what you want.
-- 
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author