So should Bash report a syntax error?

2018-02-08 15:24 GMT+01:00 Clark Wang <dearv...@gmail.com>:

> On Thu, Feb 8, 2018 at 9:05 PM, Jaan Vajakas <jaan.vaja...@gmail.com>
> wrote:
>
>> Hi!
>>
>> I noticed a weird behavior. Is it a bug?
>>
>> Namely, why does
>>
>> echo "$(for f in a b c; do if [[ \"$f\" > b ]]; then echo "$f > b"; else
>> echo "$f <= b"; fi; done)"
>>
>
> Should be:
>
>   echo "$(for f in a b c; do if [[ $f > b ]]; then echo "$f > b"; else
> echo "$f <= b"; fi; done)"
>
>
>> output
>>
>> a <= b
>> b > b
>> c > b
>>
>> ?
>>
>> I would have expected the same output as one of
>> echo "$(for f in a b c; do if [[ "$f" > b ]]; then echo "$f > b"; else
>> echo
>> "$f <= b"; fi; done)"
>> echo "$(for f in a b c; do if [[ '"$f"' > b ]]; then echo "$f > b"; else
>> echo "$f <= b"; fi; done)"
>>
>> This happens e.g. on GNU Bash v4.4 (e.g.
>> https://www.tutorialspoint.com/execute_bash_online.php ).
>>
>>
>> Best regards,
>> Jaan
>>
>
>

Reply via email to