Skip to content

Loading…

Build fix for NetBSD and other systems where /bin/sh isn't bash #90

Closed
wants to merge 2 commits into from

3 participants

@sgravrock

This fixes a build failure on NetBSD. test/run_tests.sh runs under /bin/sh but contains some bash-isms, particularly the way arithmetic is done. It fails on systems where /bin/sh isn't bash or a similar-enough shell.

I changed the #! line to /bin/bash. I could have converted the bash-isms instead, but I figured that it would be more likely to keep working in the future if users run the script under the same shell that's used to develop it.

@sgravrock sgravrock Build fix for NetBSD and other systems where /bin/sh isn't bash
Fixed by explicitly using /bin/bash. Removing bash-isms would also
work. But /bin/sh is bash on most developers' systems, so using that
shell explicitly seems like it's less likely to break in the future.
61e78ca
@emaste

FreeBSD 9.1's /bin/sh has no problem with run_tests.sh.

Does NetBSD allow x=$((x + 1))? I think it'd be better to rewrite the expression than require bash.

@sgravrock

I'm not clear on what the colon operator was being used for, here and elsewhere. On NetBSD sh, the expressions that followed it had no effect. The result was a bogus failure if this colon was left in or an infinite loop if the one on line 80 was left in. It seems to work fine without them on bash as well as NetBSD sh, but this could use another pair of eyes just to be safe.

@sgravrock

x=$(($x + 1)) works on NetBSD and ought to work on any other non-ancient sh. I've tested my latest commit in this PR on bash and NetBSD sh. I'll try it out on ash when I get a chance, but I'll be pretty surprised if it doesn't work.

@lloyd lloyd closed this in 4c539cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 15, 2012
  1. @sgravrock

    Build fix for NetBSD and other systems where /bin/sh isn't bash

    sgravrock committed
    Fixed by explicitly using /bin/bash. Removing bash-isms would also
    work. But /bin/sh is bash on most developers' systems, so using that
    shell explicitly seems like it's less likely to break in the future.
Commits on Dec 22, 2012
  1. @sgravrock
Showing with 3 additions and 3 deletions.
  1. +3 −3 test/run_tests.sh
View
6 test/run_tests.sh
@@ -70,19 +70,19 @@ for file in cases/*.json ; do
$testBin $allowPartials $allowComments $allowGarbage $allowMultiple -b $iter < $file > ${file}.test 2>&1
diff ${DIFF_FLAGS} ${file}.gold ${file}.test > ${file}.out
if [ $? -eq 0 ] ; then
- if [ $iter -eq 31 ] ; then : $(( testsSucceeded += 1)) ; fi
+ if [ $iter -eq 31 ] ; then testsSucceeded=$(( $testsSucceeded + 1 )) ; fi
else
success="FAILURE"
iter=32
${ECHO}
cat ${file}.out
fi
- : $(( iter += 1 ))
+ iter=$(( iter + 1 ))
rm ${file}.test ${file}.out
done
${ECHO} $success
- : $(( testsTotal += 1 ))
+ testsTotal=$(( testsTotal + 1 ))
done
${ECHO} $testsSucceeded/$testsTotal tests successful
Something went wrong with that request. Please try again.