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

2023-02-24 Thread Qingsheng Huang
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"  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, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/


Re: Behaviour of an empty conditional expression is undefined?

2023-02-24 Thread Chet Ramey

On 2/24/23 4:13 AM, Qingsheng Huang wrote:


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.


I can't reproduce it, either. An operand like `3+3' is just a string, and
will return a 0 status because it's non-empty.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/