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

2015-04-01 Thread Dan Douglas
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 orm...@gmail.com
Date: Wed, Apr 1, 2015 at 12:15 PM
Subject: Re: [shellcheck] Bash arithmetic expansion diagnostics (#255)
To: koalaman/shellcheck
reply+0003e7c2a607770e1564420080ff167a99c7ac0c55c501de92cf00011133a16592a169ce02dfd...@reply.github.com


On Wed, Apr 1, 2015 at 7:07 AM, brother notificati...@github.com 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 ${slotaddr[@]}
 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.



Re: Incomplete 'command not found' error message if command name contains spaces

2015-04-01 Thread Allodoxaphobia
On Tue, 31 Mar 2015 15:39:13 -0500, John McKown wrote:
 Hum, on my system, I get the message you are expecting. Transcript:
 -snip-

And, here...
This is puzzling.
On an older Ubuntu 10.04 system I still use (I know, I know...) I
get _no_ response.  But the return code appears correct:

jonesy@nix4:~$ uname -a
Linux nix4 2.6.32-39-generic #86-Ubuntu SMP Mon Feb 13 21:47:32 UTC 2012 i686 
GNU/Linux
jonesy@nix4:~$ bash -version
GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
http://gnu.org/licenses/gpl.html
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
jonesy@nix4:~$ echo $?
0
jonesy@nix4:~$ a nonexistent command with spaces
jonesy@nix4:~$ echo $?
127
jonesy@nix4:~$

However on my FreeBSD VPS it works as expected:

[jonz~]uname -a
FreeBSD xxx..net 10.1-RELEASE-p6 FreeBSD 10.1-RELEASE-p6 #0: Tue Feb 24 
19:00:21 UTC 2015
[jonz~]bash -version
GNU bash, version 4.3.33(0)-release (amd64-portbld-freebsd10.1)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
http://gnu.org/licenses/gpl.html
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[jonz~]echo $?
0
[jonz~]a nonexistent command with spaces
-bash: a nonexistent command with spaces: command not found
[jonz~]echo $?
127
[jonz~]

Jonesy
-- 
  Marvin L Jones| Marvin  | W3DHJ  | linux
   38.238N 104.547W |  @ jonz.net | Jonesy |  OS/2
* Killfiling google  banter.com: jonz.net/ng.htm



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

2015-04-01 Thread Eduardo A . Bustamante López
Already fixed:

dualbus@yaqui:~/local/src/gnu/bash$ for ((; 1(1) ;)); do break; done
dualbus@yaqui:~/local/src/gnu/bash$ 
GNU bash, version 4.4.0(1)-devel (x86_64-unknown-linux-gnu)

On Wed, Apr 01, 2015 at 12:53:16PM -0500, Dan Douglas wrote:
 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



Re: Incomplete 'command not found' error message if command name contains spaces

2015-04-01 Thread Greg Wooledge
On Wed, Apr 01, 2015 at 05:21:42PM +, Allodoxaphobia wrote:
 On an older Ubuntu 10.04 system I still use (I know, I know...) I
 get _no_ response.  But the return code appears correct:
 
 jonesy@nix4:~$ uname -a
 Linux nix4 2.6.32-39-generic #86-Ubuntu SMP Mon Feb 13 21:47:32 UTC 2012 i686 
 GNU/Linux
 jonesy@nix4:~$ bash -version
 GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)
 Copyright (C) 2009 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later 
 http://gnu.org/licenses/gpl.html
 This is free software; you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.
 jonesy@nix4:~$ echo $?
 0
 jonesy@nix4:~$ a nonexistent command with spaces
 jonesy@nix4:~$ echo $?
 127

Check what your command_not_found_handle function is set to do.
Many Linux distributions create one in the default user profiles, and
as we've seen earlier in this thread, some of them have bugs.



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

2015-04-01 Thread Dan Douglas
On Wed, Apr 1, 2015 at 1:01 PM, Eduardo A. Bustamante López
dual...@gmail.com wrote:
 Already fixed:

 dualbus@yaqui:~/local/src/gnu/bash$ for ((; 1(1) ;)); do break; done
 dualbus@yaqui:~/local/src/gnu/bash$
 GNU bash, version 4.4.0(1)-devel (x86_64-unknown-linux-gnu)

 On Wed, Apr 01, 2015 at 12:53:16PM -0500, Dan Douglas wrote:
 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

Oh awesome, nevermind then! :)