|
From: | David Maas |
Subject: | Bug in syntax checking causes unintended running of a function |
Date: | Tue, 19 Apr 2016 07:45:27 -0700 |
It didn't run the function. The function-syntax-checking scope simplyOn Tue, Apr 19, 2016 at 3:52 AM, David Maas <david.maas@gmail.com> wrote:
> Hi! I found a bug in bash, I've checked versions 4.1 (centos 6.7), 4.2
> (centos 7.2), and 4.3.30 (from the ftp site). The bug is that if you do a
> double parenthesis math thing with the wrong syntax, the script runs the
> function during what I assume is syntax checking. Demonstration script is
> attached.
>
>
> -------------- Script --------------
>
> #!/bin/bash
> #Should be avg=((avg+6))
>
> function neverrunme
> {
> avg=0
> avg=(($avg+6))
> echo -n "This function was never called. Bash version:"
> /bin/bash --version | head -1
> }
>
> echo "Welcome to this demonstration."
>
> -------------- Output --------------
>
>
> [dm5284@juphub ~]$ ./test-file.sh
> ./test-file.sh: line 7: syntax error near unexpected token `('
> ./test-file.sh: line 7: ` avg=(($avg+6))'
> This function was never called. Bash version:GNU bash, version
> 4.2.46(1)-release (x86_64-redhat-linux-gnu)
> ./test-file.sh: line 10: syntax error near unexpected token `}'
> ./test-file.sh: line 10: `}'
ended in `avg=(($avg+6))`.
[Prev in Thread] | Current Thread | [Next in Thread] |