bug-bash
[Top][All Lists]
Advanced

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

Fwd: [shellcheck] Bash arithmetic expansion diagnostics (#255)


From: Dan Douglas
Subject: Fwd: [shellcheck] Bash arithmetic expansion diagnostics (#255)
Date: Wed, 1 Apr 2015 12:53:16 -0500

Hi, This was noticed in a comment to a github issue. Just forwarding it along.

    $ for ((; 1>(1) ;)); do break; done
     -bash: syntax error near unexpected token `newline'

    $ echo "$BASH_VERSION"
    4.3.33(1)-release

https://github.com/koalaman/shellcheck/issues/255#issuecomment-88452555

---------- Forwarded message ----------
From: Dan Douglas <address@hidden>
Date: Wed, Apr 1, 2015 at 12:15 PM
Subject: Re: [shellcheck] Bash arithmetic expansion diagnostics (#255)
To: koalaman/shellcheck
<address@hidden>


On Wed, Apr 1, 2015 at 7:07 AM, brother <address@hidden> wrote:
>
> I walked straight into one of these. It looks like something might have 
> changed in bash on top of everything else because it was not new code that 
> exploded in my face, but I have indeed a new bash version on this machine 
> since last time I tried it.
>
> brother ~$ cat /tmp/test.sh
> #!/bin/bash
>
> slots=14
>
> unset slotaddr
> for ((i=0x82 ; i<((0x82+(slots*2))) ; i=i+2 )); do
>     slotaddr+=($i)
> done
>
> echo "address@hidden"
> brother ~$ shellcheck /tmp/test.sh
> brother ~$ /tmp/test.sh
> /tmp/test.sh: command substitution: line 9: syntax error near unexpected 
> token `slots*2'
> /tmp/test.sh: command substitution: line 9: `(0x82+(slots*2))) ; i=i+2 '
> /tmp/test.sh: line 6: syntax error: arithmetic expression required
> /tmp/test.sh: line 6: syntax error: `((i=0x82 ; i<((0x82+(slots*2))) ; i=i+2 
> ))'
>
> on bash 4.3.30(1)-release


That's a bug. There were some changes to the way C-for was parsed
during 4.2. Or it's possibly related to when process substitution was
removed from certain arithmetic contexts during that time.



reply via email to

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