From 4f7977b8f13d6c354f16ab22cbf54a99ca69bfa0 Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 00:51:52 +0200 Subject: [PATCH 01/12] Use $(...) instead of legacy `...` https://github.com/koalaman/shellcheck/wiki/SC2006 --- tools/build.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 From 15e84d3757507034b8766e5b01dff2c6a298eb53 Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 00:52:44 +0200 Subject: [PATCH 02/12] Use $(...) instead of legacy `...` https://github.com/koalaman/shellcheck/wiki/SC2006 --- tools/mkdoc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/mkdoc.sh b/tools/mkdoc.sh index c58419e..1efa8c2 100755 --- a/tools/mkdoc.sh +++ b/tools/mkdoc.sh @@ -1,6 +1,6 @@ #!/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 From 2eef1edef32c58d822b593ab8dec7189bc6ac2da Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 00:53:57 +0200 Subject: [PATCH 03/12] Use cd ... || exit in case cd fails https://github.com/koalaman/shellcheck/wiki/SC2164 --- tools/mkdoc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mkdoc.sh b/tools/mkdoc.sh index 1efa8c2..b06da9e 100755 --- a/tools/mkdoc.sh +++ b/tools/mkdoc.sh @@ -5,7 +5,7 @@ djsdoc=$d1/tools/jsdoc-toolkit djs=$d1/lib ddoc=$d1/doc -cd $djsdoc +cd $djsdoc || exit 1 echo "JSDoc:" rm -rf $ddoc mkdir $ddoc From 148e55383af856b5776feac74448ff4d2b7f4b9b Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 00:54:45 +0200 Subject: [PATCH 04/12] Use cd ... || exit in case cd fails. https://github.com/koalaman/shellcheck/wiki/SC2164 --- tools/deploy/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/deploy/test.sh b/tools/deploy/test.sh index 37c818e..c4e7120 100755 --- a/tools/deploy/test.sh +++ b/tools/deploy/test.sh @@ -1,5 +1,5 @@ #!/bin/bash -cd `dirname $0` +cd `dirname $0` || exit 1 source config.sh version=`cat version.txt` rm -f wintests.log mactests.txt @@ -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 From b8b102a0cebc6f01ba20950918f1e3e48ee74183 Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 00:55:24 +0200 Subject: [PATCH 05/12] Use $(...) instead of legacy `...` https://github.com/koalaman/shellcheck/wiki/SC2006 --- tools/deploy/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/deploy/test.sh b/tools/deploy/test.sh index c4e7120..83d68a5 100755 --- a/tools/deploy/test.sh +++ b/tools/deploy/test.sh @@ -1,7 +1,7 @@ #!/bin/bash -cd `dirname $0` || exit 1 +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 .. From c84424aa7a911d1ccaa88096fc8f734aea675ffb Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 00:56:42 +0200 Subject: [PATCH 06/12] Use $(...) instead of legacy `...` https://github.com/koalaman/shellcheck/wiki/SC2006 --- tools/deploy/clean.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/deploy/clean.sh b/tools/deploy/clean.sh index f8e3db2..39e273c 100755 --- a/tools/deploy/clean.sh +++ b/tools/deploy/clean.sh @@ -1,9 +1,9 @@ #!/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 rm -rf $x From 53c3c2bd49adc931406df727ca9fe6cc4046e0b9 Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 00:57:33 +0200 Subject: [PATCH 07/12] Prefer [ p ] && [ q ] over [ p -a q ] https://github.com/koalaman/shellcheck/wiki/SC2166 --- tools/deploy/clean.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/deploy/clean.sh b/tools/deploy/clean.sh index 39e273c..c6fb6b5 100755 --- a/tools/deploy/clean.sh +++ b/tools/deploy/clean.sh @@ -5,7 +5,7 @@ cd ../../.. 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 From dda2beb333b10e5367c53bc91fccdb69cb1e2927 Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 00:58:58 +0200 Subject: [PATCH 08/12] Use $(...) instead of legacy `...` https://github.com/koalaman/shellcheck/wiki/SC2006 --- tools/deploy/stage.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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." From 4bd921a9fe9af499e542f5b5e20c8d4d1a6ee86f Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 01:02:41 +0200 Subject: [PATCH 09/12] Use $(...) instead of legacy `...` https://github.com/koalaman/shellcheck/wiki/SC2006 --- tools/deploy/deploy.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/deploy/deploy.sh b/tools/deploy/deploy.sh index e4c5c10..4048e5e 100755 --- a/tools/deploy/deploy.sh +++ b/tools/deploy/deploy.sh @@ -1,13 +1,13 @@ #!/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 From a67818e230d70060f4f62041abe4ac78a782e7d1 Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 01:06:17 +0200 Subject: [PATCH 10/12] Double quote to keep keywords as literals --- tools/deploy/deploy.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/deploy/deploy.sh b/tools/deploy/deploy.sh index 4048e5e..b894d37 100755 --- a/tools/deploy/deploy.sh +++ b/tools/deploy/deploy.sh @@ -14,7 +14,7 @@ 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/ From 1e55a2cda9e7f2480d8ebeed14695dbd968b6aec Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 01:07:36 +0200 Subject: [PATCH 11/12] Use $(...) instead of legacy `...` https://github.com/koalaman/shellcheck/wiki/SC2006 --- tools/deploy/#deploy.sh# | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/deploy/#deploy.sh# b/tools/deploy/#deploy.sh# index eab81b6..2a90e2a 100755 --- a/tools/deploy/#deploy.sh# +++ b/tools/deploy/#deploy.sh# @@ -1,13 +1,13 @@ #!/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 From edc084d6ad8d019c0de944cabfe8156b11db0b0d Mon Sep 17 00:00:00 2001 From: Androbin Date: Sat, 24 Jun 2017 01:08:31 +0200 Subject: [PATCH 12/12] Double quote to keep keywords as literals --- tools/deploy/#deploy.sh# | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/deploy/#deploy.sh# b/tools/deploy/#deploy.sh# index 2a90e2a..f3852eb 100755 --- a/tools/deploy/#deploy.sh# +++ b/tools/deploy/#deploy.sh# @@ -14,7 +14,7 @@ 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/