On 4/18/16 12:52 PM, David Maas 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.
That's close to, but not exactly, what's happening. The shell attempts to parse a function and encounters a syntax error. It has a choice at this point: abandon parsing of the current command (the function definition), or abandon the script altogether. In its default mode, bash chooses the former: abandon parsing the function definition and go on. In Posix mode, it abandons the script entirely. When it attempts to go on, it synchronizes with the next newline and attempts to parse a new command (`echo ...'), which it does successfully. When it hits the close brace that was intended to end the function definition, that's an operator an a place where it's disallowed, which generates another syntax error. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/