diff --git a/tools/build.sh b/tools/build.sh index fe3be4b..6b73dba 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -1,18 +1,18 @@ #!/bin/bash -e -home=`dirname $0` +home=$(dirname $0) cd $home if [ -f buildpid.log ]; then - buildpid=`cat buildpid.log` + buildpid=$(cat buildpid.log) kill -9 $buildpid || true rm -f buildpid.log fi echo $$ > buildpid.log if [ -f nodepid.log ]; then - nodepid=`cat nodepid.log` + nodepid=$(cat nodepid.log) kill -9 $nodepid || true rm -f nodepid.log fi -ver=`grep 'numeric.version.*=.*"' ../src/numeric.js | sed 's/numeric.version[ =]*"\([0-9.]*\)".*/\1/'` +ver=$(grep 'numeric.version.*=.*"' ../src/numeric.js | sed 's/numeric.version[ =]*"\([0-9.]*\)".*/\1/') echo "Version is $ver" cat ../src/numeric.js ../src/seedrandom.js ../src/quadprog.js ../src/svd.js > ../lib/numeric-$ver.js uglifyjs ../lib/numeric-$ver.js > ../lib/numeric-$ver.min.js @@ -44,7 +44,7 @@ cp ../src/documentation.html .. rm -f ../workshop.php sed -e '/WORKSHOPHTML/r workshop.html' -e 's/WORKSHOPHTML//' -e "s/VERSIONSTRING/$ver/" workshop_in.php > ../workshop.php cd .. -runjs=`which d8 || which jsdb || which node` +runjs=$(which d8 || which jsdb || which node) echo Using $runjs $runjs ./tools/unit2.js & echo $! > tools/nodepid.log diff --git a/tools/deploy/#deploy.sh# b/tools/deploy/#deploy.sh# index eab81b6..f3852eb 100755 --- a/tools/deploy/#deploy.sh# +++ b/tools/deploy/#deploy.sh# @@ -1,20 +1,20 @@ #!/bin/bash set -e -cd `dirname $0` +cd $(dirname $0) cd ../.. -foo=`git status --porcelain` && +foo=$(git status --porcelain) && if [ "x" != "x$foo" ]; then echo "Cannot deploy while there are uncommited changes." exit fi -ver=`grep "numeric.version =" src/numeric.js | sed 's/.*[''"]\([0-9.]*\)[''"].*/\1/'` +ver=$(grep "numeric.version =" src/numeric.js | sed 's/.*[''"]\([0-9.]*\)[''"].*/\1/') npm publish ./lib/numeric-1.1.9.tar.gz git tag v$ver git push --tags chmod a-w lib/numeric-$ver*.js cd tools/deploy source config.sh -echo Fetching staging copy... +echo "Fetching staging copy..." curl $server/staging/ > staging-copy.html if grep Loisel staging-copy.html > /dev/null; then echo "Fetched." @@ -22,18 +22,18 @@ else echo "Staging copy does not work!" exit 1 fi -echo Deploying... +echo "Deploying..." ssh $server -l $user "( cd $webroot && [ -L staging ] && foo=\`readlink staging\` && rm -f numeric && ln -s \$foo numeric && rm -f staging && numeric/tools/deploy/clean.sh && echo Deployment successful. ) || echo FAIL: Deployment unsuccessful." -echo Comparing staging copy with live copy... +echo "Comparing staging copy with live copy..." curl http://$server/ > live-copy.html if diff staging-copy.html live-copy.html >/dev/null; then - echo Staging and live copies match. + echo "Staging and live copies match." else - echo FAIL: Staging and live copies do not match. + echo "FAIL: Staging and live copies do not match." exit 1 fi rm -f staging-copy.html live-copy.html -echo Testing live links +echo "Testing live links" cd .. pwd python ./selenium_links.py Firefox http://$server/ diff --git a/tools/deploy/clean.sh b/tools/deploy/clean.sh index f8e3db2..c6fb6b5 100755 --- a/tools/deploy/clean.sh +++ b/tools/deploy/clean.sh @@ -1,11 +1,11 @@ #!/bin/bash set -e -cd `dirname $0` +cd $(dirname $0) cd ../../.. -numeric=`readlink numeric || echo ""` -staging=`readlink staging || echo ""` +numeric=$(readlink numeric || echo "") +staging=$(readlink staging || echo "") for x in v*; do - if [ "z$x" != "z$numeric" -a "z$x" != "z$staging" ]; then + if [ "z$x" != "z$numeric" ] && [ "z$x" != "z$staging" ]; then rm -rf $x fi done diff --git a/tools/deploy/deploy.sh b/tools/deploy/deploy.sh index e4c5c10..b894d37 100755 --- a/tools/deploy/deploy.sh +++ b/tools/deploy/deploy.sh @@ -1,20 +1,20 @@ #!/bin/bash set -e -cd `dirname $0` +cd $(dirname $0) cd ../.. -foo=`git status --porcelain` && +foo=$(git status --porcelain) && if [ "x" != "x$foo" ]; then echo "Cannot deploy while there are uncommited changes." exit fi -ver=`grep "numeric.version =" src/numeric.js | sed 's/.*[''"]\([0-9.]*\)[''"].*/\1/'` +ver=$(grep "numeric.version =" src/numeric.js | sed 's/.*[''"]\([0-9.]*\)[''"].*/\1/') npm publish ./lib/numeric-$ver.tar.gz git tag v$ver git push --tags chmod a-w lib/numeric-$ver*.js cd tools/deploy source config.sh -echo Fetching staging copy... +echo "Fetching staging copy..." curl $server/staging/ > staging-copy.html if grep Loisel staging-copy.html > /dev/null; then echo "Fetched." @@ -22,18 +22,18 @@ else echo "Staging copy does not work!" exit 1 fi -echo Deploying... +echo "Deploying..." ssh $server -l $user "( cd $webroot && [ -L staging ] && foo=\`readlink staging\` && rm -f numeric && ln -s \$foo numeric && rm -f staging && numeric/tools/deploy/clean.sh && echo Deployment successful. ) || echo FAIL: Deployment unsuccessful." -echo Comparing staging copy with live copy... +echo "Comparing staging copy with live copy..." curl http://$server/ > live-copy.html if diff staging-copy.html live-copy.html >/dev/null; then - echo Staging and live copies match. + echo "Staging and live copies match." else - echo FAIL: Staging and live copies do not match. + echo "FAIL: Staging and live copies do not match." exit 1 fi rm -f staging-copy.html live-copy.html -echo Testing live links +echo "Testing live links" cd .. pwd python ./selenium_links.py Firefox http://$server/ diff --git a/tools/deploy/stage.sh b/tools/deploy/stage.sh index d543cff..b1f2a03 100755 --- a/tools/deploy/stage.sh +++ b/tools/deploy/stage.sh @@ -1,13 +1,13 @@ #!/bin/bash set -e -version=`date "+%Y-%m-%d_%H-%M-%S"` -cd `dirname $0` +version=$(date "+%Y-%m-%d_%H-%M-%S") +cd $(dirname $0) rm -f version.txt echo $version > version.txt source config.sh cd ../../ -ver=`grep "numeric.version =" src/numeric.js | sed 's/.*[''"]\([0-9.]*\)[''"].*/\1/'` -foo=`git tag -l v$ver` +ver=$(grep "numeric.version =" src/numeric.js | sed 's/.*[''"]\([0-9.]*\)[''"].*/\1/') +foo=$(git tag -l v$ver) if [ "x$foo" != "x" ]; then echo "The version $ver already exists." echo "You must update the version number in numeric.js." diff --git a/tools/deploy/test.sh b/tools/deploy/test.sh index 37c818e..83d68a5 100755 --- a/tools/deploy/test.sh +++ b/tools/deploy/test.sh @@ -1,7 +1,7 @@ #!/bin/bash -cd `dirname $0` +cd $(dirname $0) || exit 1 source config.sh -version=`cat version.txt` +version=$(cat version.txt) rm -f wintests.log mactests.txt echo "test.sh: launching IE unit tests" cd .. @@ -24,6 +24,6 @@ echo "test.sh: Mac/Firefox unit tests on $server/staging" python -u selenium_tests.py Firefox http://$server/staging/ >> $logfile 2>&1 kill -9 $tailpid echo "test.sh: making report" -cd deploy +cd deploy || exit 1 python make_report.py $version > report.html scp report.html $user@$server:$webroot/staging diff --git a/tools/mkdoc.sh b/tools/mkdoc.sh index c58419e..b06da9e 100755 --- a/tools/mkdoc.sh +++ b/tools/mkdoc.sh @@ -1,11 +1,11 @@ #!/bin/bash -d0=`dirname $0` -d1=`cd $d0/.. && pwd` +d0=$(dirname $0) +d1=$(cd $d0/.. && pwd) djsdoc=$d1/tools/jsdoc-toolkit djs=$d1/lib ddoc=$d1/doc -cd $djsdoc +cd $djsdoc || exit 1 echo "JSDoc:" rm -rf $ddoc mkdir $ddoc