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: Greg Wooledge
Subject: Re: Syntax error near unexpected token `newline' within loops
Date: Mon, 24 Apr 2017 08:58:07 -0400
User-agent: Mutt/1.4.2.3i

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.

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



reply via email to

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