Hi all,
This is my first post to this mailing list. If I'm doing anything that
is not right, please do let me know.
While upgrading my company's Linux distribution, I also upgrade Bash to
version 4.2-10, and found a glitch, that I consider a BUG. However I
might be doing something wrong. Here are the details:
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...
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 ?
Thanks for all your help,
--
Regards,
Rui Santos
diff -ruN bash-4.2-10.ori/subst.c bash-4.2-10.new/subst.c
--- bash-4.2-10.ori/subst.c 2011-06-21 15:46:26.000000000 +0100
+++ bash-4.2-10.new/subst.c 2011-06-24 17:50:44.000000000 +0100
@@ -1266,6 +1266,7 @@
continue;
}
+#if 0
/* Process a nested command substitution, but only if we're parsing an
arithmetic substitution. */
if ((flags & SX_COMMAND) && string[i] == '$' && string[i+1] == LPAREN)
@@ -1275,6 +1276,7 @@
i = si + 1;
continue;
}
+#endif
/* Process a nested OPENER. */
if (STREQN (string + i, opener, len_opener))