bug-bash
[Top][All Lists]
Advanced

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

Re:Re: Behaviour of an empty conditional expression is undefined?


From: Qingsheng Huang
Subject: Re:Re: Behaviour of an empty conditional expression is undefined?
Date: Fri, 24 Feb 2023 17:13:24 +0800 (CST)

Thanks for the bug-fixing and pointing out my misunderstanding of builtin.  

I find that conditional expressions like ``[[ 3+3 ]]'' sometimes triger the bug,
though I cannot repeat it.  I hope it also get fixed in the previous version.










At 2023-02-23 23:23:11, "Chet Ramey" <chet.ramey@case.edu> wrote:
>On 2/23/23 3:26 AM, Qingsheng Huang wrote:
>> Here shows the behavious of empty conditional expressions:
>> 
>> ------------------------------------------------------------------------
>> infinite:~# [[ ]]
>> -bash: syntax error near unexpected token `]]'
>> infinite:~# [[ ]]
>> infinite:~# [[ "$A" ]]
>> -bash: syntax error near unexpected token `"$A"'
>
>This is a bug having to do with resetting the parser state in an
>interactive shell after an error token. It was fixed back in October as
>the  result of
>
>https://savannah.gnu.org/support/?110745
>
>and the fix is in the devel branch. It's ironic that this is the exact
>same issue we discussed yesterday in
>
>https://lists.gnu.org/archive/html/bug-bash/2023-02/msg00150.html
>
>with a slightly different effect.
>
>
>> According to the manual, I think an empty condition like ``[[   ]]'' and
>> ``[[ $EMPTY ]]'' should always triger syntax error,
>
>No. There has to be at least one operand of [[, but since word expansions
>are not performed until [[ executes, a variable expansion is a valid
>operand. That's the difference between a compound command and a builtin.
>
>
>-- 
>``The lyf so short, the craft so long to lerne.'' - Chaucer
>                ``Ars longa, vita brevis'' - Hippocrates
>Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

reply via email to

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