Re: Curious case of arithmetic expansion

2017-04-24 Thread Florian Mayer
Ok, I accept your points, but please read on and decide after that. > to do anything but assign a value to `var'. Very few people, when asked, > would say that it were more intuitive to cause a variable named `bar' to > spring into existence with the value 7. If you want nameref behavior, you > h

Syntax error near unexpected token `newline' within loops

2017-04-24 Thread werner
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.4 -L/home/abuild/rpmbuild/BUILD/bash-4.4/../readline-7.0 Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -D

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

2017-04-24 Thread Pierre Gaston
On Mon, Apr 24, 2017 at 1:59 PM, wrote: > (...) > > and yes > > V_NAME=Friday > for (( INDEX=0; INDEX<$((10-${#V_NAME})) ; INDEX++ )) > do > echo $INDEX > done > > does also work, nevertheless using $(...) in the very first example is > allowed > > or e

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

2017-04-24 Thread Dr. Werner Fink
On Mon, Apr 24, 2017 at 02:25:41PM +0300, Pierre Gaston wrote: > On Mon, Apr 24, 2017 at 1:59 PM, wrote: > > > (...) > > > > and yes > > > > V_NAME=Friday > > for (( INDEX=0; INDEX<$((10-${#V_NAME})) ; INDEX++ )) > > do > > echo $INDEX > > done > > > >

Re: Curious case of arithmetic expansion

2017-04-24 Thread Steve Amerige
It is essential to not break backward compatibility. Imagine the huge number of scripts that would be impacted by the semantic shift you're suggesting. If a proposal were to be made that would cause backward incompatibility, then any such proposal should be reject

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

2017-04-24 Thread Greg Wooledge
On Mon, Apr 24, 2017 at 12:59:01PM +0200, wer...@suse.de wrote: > V_NAME=Friday > for (( INDEX=0; INDEX<$((10-$(expr length $V_NAME))); INDEX++ )) The outer (( )) in the C-style for loop already create an arithmetic expression context. You don't need to use $(( )) inside them. You ca

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

2017-04-24 Thread Eduardo Bustamante
On Mon, Apr 24, 2017 at 7:44 AM, Greg Wooledge 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

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

2017-04-24 Thread Dr. Werner Fink
On Mon, Apr 24, 2017 at 08:44:11AM -0400, Greg Wooledge wrote: > On Mon, Apr 24, 2017 at 12:59:01PM +0200, wer...@suse.de wrote: > > V_NAME=Friday > > for (( INDEX=0; INDEX<$((10-$(expr length $V_NAME))); INDEX++ )) > > The outer (( )) in the C-style for loop already create an arithmetic >

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

2017-04-24 Thread Greg Wooledge
On Mon, Apr 24, 2017 at 07:49:36AM -0500, Eduardo Bustamante wrote: > On Mon, Apr 24, 2017 at 7:44 AM, Greg Wooledge 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:

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

2017-04-24 Thread Reuti
> Am 24.04.2017 um 14:58 schrieb Greg Wooledge : > > On Mon, Apr 24, 2017 at 07:49:36AM -0500, Eduardo Bustamante wrote: >> On Mon, Apr 24, 2017 at 7:44 AM, Greg Wooledge wrote: >> [...] >>> The outer (( )) in the C-style for loop already create an arithmetic >>> expression context. You don't n

Re: Using Clang's static analyzer on bash

2017-04-24 Thread Chet Ramey
On 4/23/17 9:02 PM, Eduardo Bustamante wrote: > I built bash using scan-build > (https://clang-analyzer.llvm.org/scan-build.html) and I noticed that > it was able to detect the null pointer dereference reported earlier by > Jaren (https://lists.gnu.org/archive/html/bug-bash/2017-04/msg00100.html).

Re: Curious case of arithmetic expansion

2017-04-24 Thread Chet Ramey
On 4/24/17 3:59 AM, Florian Mayer wrote: > Ok, I accept your points, but please read on and decide after that. > >> to do anything but assign a value to `var'. Very few people, when asked, >> would say that it were more intuitive to cause a variable named `bar' to >> spring into existence with th

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

2017-04-24 Thread Chet Ramey
On 4/24/17 6:59 AM, wer...@suse.de wrote: > Bash Version: 4.4 > Patch Level: 12 > Release Status: release > > Description: > Since 4.3 including 4.4 bash shows a bug in loops using nested ((...)), > $((..)), and $(...) > > Repeat-By: > The bash code > > V_NAME=Friday > for ((

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

2017-04-24 Thread Chet Ramey
On 4/24/17 8:58 AM, Greg Wooledge wrote: > Seriously, "expr length"?! In a script that is already using bashisms? That works on Linux, but not on the BSDs, since Posix says it doesn't have to. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita br