Skip to content

Commit

Permalink
Apply suggestions from shellcheck
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Feb 3, 2024
1 parent cd02da5 commit ae34547
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 89 deletions.
6 changes: 3 additions & 3 deletions benchmarks/Crystal/build.sh
Original file line number Diff line number Diff line change
@@ -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"

if [[ "$1" = "style" ]]
then
exit 0
fi

INFO Build Crystal Benchmarks
pushd $SCRIPT_PATH
pushd "$SCRIPT_PATH"
crystal build --release --no-debug harness.cr
6 changes: 3 additions & 3 deletions benchmarks/Java/build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/JavaScript/build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/Lua/build.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions benchmarks/Python/build.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions benchmarks/Ruby/build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/SOM/build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/SOMns/build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Smalltalk/build.sh
Original file line number Diff line number Diff line change
@@ -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" ]]
Expand Down
72 changes: 7 additions & 65 deletions benchmarks/script.inc
Original file line number Diff line number Diff line change
@@ -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; }
Expand All @@ -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" ]]
Expand All @@ -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
Expand Down

0 comments on commit ae34547

Please sign in to comment.