bug-bash
[Top][All Lists]
Advanced

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

Re: Syntax error near unexpected token `newline' within loops


From: Reuti
Subject: Re: Syntax error near unexpected token `newline' within loops
Date: Mon, 24 Apr 2017 15:01:41 +0200

> Am 24.04.2017 um 14:58 schrieb Greg Wooledge <wooledg@eeg.ccf.org>:
> 
> On Mon, Apr 24, 2017 at 07:49:36AM -0500, Eduardo Bustamante wrote:
>> On Mon, Apr 24, 2017 at 7:44 AM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
>> [...]
>>> The outer (( )) in the C-style for loop already create an arithmetic
>>> expression context.  You don't need to use $(( )) inside them.  You can
>>> simply write:
>>> 
>>> for (( INDEX=0; INDEX<10-${#V_NAME};; INDEX++ ))
>> 
>> I think this is just to show the bug. i.e. these two should do the same:
>> 
>> dualbus@debian:~$ bash -c 'for (( ; $(($(:))); )); do :; done'
>> bash: -c: line 0: syntax error near unexpected token `newline'
>> bash: -c: line 0: `for (( ; $(($(:))); )); do :; done'
>> 
>> dualbus@debian:~$ bash -c 'for (( ; $((`:`)); )); do :; done'
> 
> Yeah, I'm not disputing whether there's actually a bug here, just
> pointing out that the code can be simplified to avoid it.  The fact that
> no sane person should write code this way is probably why the bug went
> undiscovered for so long.

AFAICS in version 4.2.45(1) it works as expected.

-- Reuti


> Seriously, "expr length"?!  In a script that is already using bashisms?

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail


reply via email to

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