Revision 1.24 of ld/genscripts.sh introduced the following code: if test -n "${BASH+set}"; then source_em() { local current_script="$em_script" em_script=$1 . $em_script em_script=$current_script } fragment() { local lineno=$[${BASH_LINENO[0]} + 1] ###### <--- echo >> e${EMULATION_NAME}.c "#line $lineno \"$em_script\"" cat >> e${EMULATION_NAME}.c } This breaks on FreeBSD's /bin/sh with the following message: .././ld/genscripts.sh: 403: Syntax error: Bad substitution (Line 403 is marked with ###### <--- above.) The issue here is that FreeBSD's /bin/sh simply does not recognize the *syntax* of the array substitution, so the test for ${BASH} above doesn't matter at all -- the shell aborts parsing the script at that point. So somehow, the test for using a bash should either be moved into a configure-time substitution, or the array (and math, too?) substitution should be replaced by something else that can be handled by any flavor of /bin/sh. FreeBSD's /bin/sh doesn't choke on the $[] math invoked (it simply doesn't sustitute anything), yet I figure some other /bin/sh might also consider that a syntax error. IMHO it's just riding on the safe side to use plain old expr(1).
Would /bin/sh be happy with the following? if test -n "${BASH+set}"; then . ${srcdir}/gen.bash else ... ie. hide the bash specific syntax in another file?
(In reply to comment #1) > Would /bin/sh be happy with the following? > > if test -n "${BASH+set}"; then > . ${srcdir}/gen.bash > else Yes, that appears to work for FreeBSD's /bin/sh. Currently cannot test an archaic /bin/sh (like Solaris) though, and it might be wise to at least try finding out what Posix says about it.
http://sourceware.org/ml/binutils-cvs/2007-10/msg00179.html