diff --git a/benchmarks/Crystal/build.sh b/benchmarks/Crystal/build.sh index 4ecc739b..8a9f2c81 100755 --- a/benchmarks/Crystal/build.sh +++ b/benchmarks/Crystal/build.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e # make script fail on first error -SCRIPT_PATH=$(dirname $0) -source $SCRIPT_PATH/../script.inc +SCRIPT_PATH="$(dirname "$0")" +source "$SCRIPT_PATH/../script.inc" if [[ "$1" = "style" ]] then @@ -9,5 +9,5 @@ then fi INFO Build Crystal Benchmarks -pushd $SCRIPT_PATH +pushd "$SCRIPT_PATH" crystal build --release --no-debug harness.cr diff --git a/benchmarks/Java/build.sh b/benchmarks/Java/build.sh index d137c833..aa5375e3 100755 --- a/benchmarks/Java/build.sh +++ b/benchmarks/Java/build.sh @@ -1,8 +1,8 @@ #!/bin/bash set -e # make script fail on first error -SCRIPT_PATH=$(dirname $0) -source $SCRIPT_PATH/../script.inc -pushd $SCRIPT_PATH +SCRIPT_PATH="$(dirname "$0")" +source "$SCRIPT_PATH/../script.inc" +pushd "$SCRIPT_PATH" if [[ "$1" = "style" ]] then diff --git a/benchmarks/JavaScript/build.sh b/benchmarks/JavaScript/build.sh index ac7a0655..e06860d8 100755 --- a/benchmarks/JavaScript/build.sh +++ b/benchmarks/JavaScript/build.sh @@ -1,13 +1,13 @@ #!/bin/bash set -e # make script fail on first error -SCRIPT_PATH=$(dirname $0) -source $SCRIPT_PATH/../script.inc +SCRIPT_PATH="$(dirname "$0")" +source "$SCRIPT_PATH/../script.inc" INFO Build Node.js Benchmarks if [[ "$1" = "style" ]] then INFO Check style of JavaScript benchmarks - pushd $SCRIPT_PATH + pushd "$SCRIPT_PATH" npx eslint . else exit 0 diff --git a/benchmarks/Lua/build.sh b/benchmarks/Lua/build.sh index 3d399dd9..6a8b50ae 100755 --- a/benchmarks/Lua/build.sh +++ b/benchmarks/Lua/build.sh @@ -1,13 +1,13 @@ #!/bin/bash set -e # make script fail on first error -SCRIPT_PATH=$(dirname $0) +SCRIPT_PATH="$(dirname "$0")" source $SCRIPT_PATH/../script.inc if [[ "$1" = "style" ]] then INFO Check style of Lua benchmarks - pushd $SCRIPT_PATH - luacheck *.lua + pushd "$SCRIPT_PATH" + luacheck ./*.lua else exit 0 fi diff --git a/benchmarks/Python/build.sh b/benchmarks/Python/build.sh index 123d4d92..aaccec13 100755 --- a/benchmarks/Python/build.sh +++ b/benchmarks/Python/build.sh @@ -1,16 +1,16 @@ #!/bin/bash set -e # make script fail on first error -SCRIPT_PATH=$(dirname $0) -source $SCRIPT_PATH/../script.inc +SCRIPT_PATH="$(dirname "$0")" +source "$SCRIPT_PATH/../script.inc" if [[ "$1" = "style" ]] then INFO Check style of Python benchmarks - pushd $SCRIPT_PATH + pushd "$SCRIPT_PATH" if [[ "$2" != "skip-black-for-python" ]]; then python -m black --check --diff . fi - python -m pylint *.py som + python -m pylint ./*.py som else exit 0 fi diff --git a/benchmarks/Ruby/build.sh b/benchmarks/Ruby/build.sh index a8b5e839..11f77863 100755 --- a/benchmarks/Ruby/build.sh +++ b/benchmarks/Ruby/build.sh @@ -1,12 +1,12 @@ #!/bin/bash set -e # make script fail on first error -SCRIPT_PATH=$(dirname $0) -source $SCRIPT_PATH/../script.inc +SCRIPT_PATH="$(dirname "$0")" +source "$SCRIPT_PATH/../script.inc" if [[ "$1" = "style" ]] then INFO Check style of Ruby benchmarks - pushd $SCRIPT_PATH + pushd "$SCRIPT_PATH" rubocop else exit 0 diff --git a/benchmarks/SOM/build.sh b/benchmarks/SOM/build.sh index f81465da..7b265223 100755 --- a/benchmarks/SOM/build.sh +++ b/benchmarks/SOM/build.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e # make script fail on first error -SCRIPT_PATH=$(dirname $0) -source $SCRIPT_PATH/../script.inc +SCRIPT_PATH="$(dirname "$0")" +source "$SCRIPT_PATH/../script.inc" if [[ "$1" = "style" ]] then diff --git a/benchmarks/SOMns/build.sh b/benchmarks/SOMns/build.sh index f81465da..7b265223 100755 --- a/benchmarks/SOMns/build.sh +++ b/benchmarks/SOMns/build.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e # make script fail on first error -SCRIPT_PATH=$(dirname $0) -source $SCRIPT_PATH/../script.inc +SCRIPT_PATH="$(dirname "$0")" +source "$SCRIPT_PATH/../script.inc" if [[ "$1" = "style" ]] then diff --git a/benchmarks/Smalltalk/build.sh b/benchmarks/Smalltalk/build.sh index 49b75f60..21c00506 100755 --- a/benchmarks/Smalltalk/build.sh +++ b/benchmarks/Smalltalk/build.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e # make script fail on first error -SCRIPT_PATH="$(dirname $0)" +SCRIPT_PATH="$(dirname "$0")" source "$SCRIPT_PATH/../script.inc" if [[ "$1" = "style" ]] diff --git a/benchmarks/script.inc b/benchmarks/script.inc index c943707a..52022429 100755 --- a/benchmarks/script.inc +++ b/benchmarks/script.inc @@ -1,13 +1,13 @@ #!/bin/bash # make SCRIPT_PATH absolute -pushd $(dirname $0) > /dev/null -SCRIPT_PATH=`pwd` -popd > /dev/null +pushd "$(dirname "$0")" > /dev/null || exit 1 +export SCRIPT_PATH="$(pwd)" +popd > /dev/null || exit 1 # set up color commands -if [ -t 1 -a -t 2 -a \( `type -t tput` = "file" \) ]; then - _colors=`tput colors` +if [ -t 1 ] && [ -t 2 ] && [ \( "$(type -t tput)" = "file" \) ]; then + _colors=$(tput colors) if [ "$_colors" -ge 256 ]; then INFO () { tput setaf 33; /bin/echo "$@"; tput sgr0; } OK () { tput setaf 28; /bin/echo "$@"; tput sgr0; } @@ -26,64 +26,6 @@ else ERR () { /bin/echo "$@"; } fi - -function get_web_getter() { - # get a getter - if [ \! -z `type -t curl` ]; then - GET="curl --silent --location --compressed -O" - elif [ \! -z `type -t wget` ]; then - GET="wget --quiet" - else - ERR "No getter (curl/wget)" - exit 1 - fi - OK Getter is \"$GET\" -} - -function check_for_tools() { - INFO -n 'Tools: ' - for tool in $@; do - if [ -x `type -t $tool` ]; then - WARN -n No $tool - else - INFO -n "$tool " - fi - done - OK ok. -} - -function get_pypy() { - if [ \! -d pypy ]; then - get_web_getter - - INFO Get PyPy Source - PYPY_VERSION="5.8.0" - PYPY_DIR="pypy2-v${PYPY_VERSION}-src" - PYPY_TAR="${PYPY_DIR}.tar.bz2" - DOWNLOAD_URL="https://bitbucket.org/pypy/pypy/downloads/${PYPY_TAR}" - $GET $DOWNLOAD_URL || $GET $DOWNLOAD_URL - tar -xjf $PYPY_TAR - mv $PYPY_DIR pypy - else - OK Got PyPy Source - fi -} - -function get_jdk9ea() { - JDK_ARCHIVE=jdk-9-ea+96_linux-x64_bin.tar.gz - JDK_URL=http://www.java.net/download/jdk9/archive/96/binaries/$JDK_ARCHIVE - JDK_DIR=jdk-9 - - INFO Get JDK9 Early Access from $JDK_URL - if [ \! -d "$JDK_DIR" ]; then - $GET $JDK_URL || $GET $JDK_URL - tar -xzf $JDK_ARCHIVE - OK Got JDK Early Access - else - OK Have JDK Early Access - fi -} - function load_git_repo() { INFO Cloning "$1" into "$2" if [[ -z "$3" ]] @@ -100,10 +42,10 @@ function load_submodule() { } function check_for() { - if [ ! -x `which $1` ] + if [ ! -x "$(which "$1")" ] then ERR "$1 binary not found. $2" - if [ "non-fatal" -ne "$3" ] + if [ "non-fatal" != "$3" ] then exit 1 fi