On 6/24/11 1:18 PM, Rui Santos wrote:
Try this script:
#!/bin/bash
declare -ax array
array[$(( $( echo -n 1001 ) - 1001 ))]=1
this will issue an error: line 6: 1001: command not found
If however the script is turned into:
#!/bin/bash
declare -ax array
array[$(( `echo -n 1001` - 1001 ))]=1
it works perfectly.
The first script will run without any problems on bash-4.1-9
However if, on bash 4.2-10 (where the 1st script fails), you have a script
like:
#!/bin/bash
echo $(( $( echo -n 1001 ) - 1001 ))
it also works fine.
strange...
Yes. It's a case of not saving and restoring enough state across possibly-
recursive calls to the shell parser. (The assignment statement is the key
in this case.)
So, I compared subst.c files from bash-4.1-9 and bash-4.2-10 and was able
to build a patch that it seems to make it work.
So to all you Bash guru's, can this patch be applied with no extra
consequences ?
No. The code is in there for a reason. It's part of the fix for Posix
interpretation 217 (http://austingroupbugs.net/view.php?id=217).