Skip to content

Commit

Permalink
Shellcheck cleanliness
Browse files Browse the repository at this point in the history
Sadly, this also means we have to let go of some more shells, but
that's a non-issue, since the problems with OS-X / BSD shell have
meant specifying bash anyway.
  • Loading branch information
Anders Eurenius committed Jul 7, 2016
1 parent 4f59170 commit 04adaa2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 33 deletions.
6 changes: 0 additions & 6 deletions all_shells.sh

This file was deleted.

37 changes: 16 additions & 21 deletions git-test
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ set -e

VERSION=1.0.2

NONGIT_OK=Yes
SUBDIRECTORY_OK=Yes
OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=t
OPTIONS_SPEC="\
export NONGIT_OK=Yes
export SUBDIRECTORY_OK=Yes
export OPTIONS_KEEPDASHDASH=
export OPTIONS_STUCKLONG=t
export OPTIONS_SPEC="\
git test [options] [refs...]
git test --clear [refs...]
Expand Down Expand Up @@ -96,7 +96,7 @@ progress () {
else
if [ -z "$GIT_QUIET" ]; then
if [ -n "$verbose" ] ; then
printf "$CR" 1>& $ERR
printf "%s" "$CR" 1>& $ERR
fi
printf "%04d | %s | %s | " \
"$iteration" "$short" "$small" 1>& $OUT
Expand All @@ -107,12 +107,9 @@ progress () {
}


second_word() {
echo $2
}

tree_of_commit() {
second_word $(git cat-file -p "$1" | grep tree)
words=( $(git cat-file -p "$1" | grep tree) )
printf "%s" "${words[1]}"
}

make_output_dirs() {
Expand Down Expand Up @@ -303,7 +300,7 @@ run_tests() {

link_result

iteration=$(expr $iteration + 1)
iteration=$((iteration + 1))
done
}

Expand Down Expand Up @@ -429,8 +426,8 @@ if [ $action = clear ] ; then
if test -z "$*" ; then
rm -f "$cache"/*_fail "$cache"/*_pass
else
refs="$(decide_refs "$@")"
commits="$(git rev-list --reverse $refs -- | tr "$NL" " ")"
refs=( $(decide_refs "$@") )
commits="$(git rev-list --reverse "${refs[@]}" -- | tr "$NL" " ")"
count="$(echo "$commits" | wc -w)"

if test 1 -gt "$count" ; then
Expand Down Expand Up @@ -467,17 +464,15 @@ or
exit 5
fi

refs="$(decide_refs "$@")"
refs="${refs% }"
commits="$(git rev-list --reverse $refs -- | tr "$NL" " ")"
count="$(echo "$commits" | wc -w)"
refs=( $(decide_refs "$@") )
commits=( $(git rev-list --reverse "${refs[@]}" -- | tr "$NL" " ") )
count="$(echo "${commits[@]}" | wc -w)"

if test 1 -gt "$count" ; then
gettext 'List of commits to test is empty' 1>&2
exit
elif test -z "$GIT_QUIET" ; then
eval_gettext "\$refs will test \$count commits
"
printf "$(eval_gettext "%s will test %d commits\n")" "${refs[*]}" "$count"
fi

trap "atexit_cleanup" INT TERM EXIT
Expand All @@ -486,6 +481,6 @@ lock

make_output_dirs

run_tests $commits
run_tests "${commits[@]}"

exit 1
12 changes: 6 additions & 6 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Copyright 2014-2015 Spotify AB. All rights reserved.
#
Expand All @@ -15,7 +15,7 @@
# the License.
#
export OPTIONS_SPEC="\
sh $0 [options]
bash $0 [options]
Run tests
Expand Down Expand Up @@ -45,7 +45,7 @@ last=""
pass=0
fail=0

shshell=${shshell:-/bin/sh}
shshell=${shshell:-/bin/bash}

total_argc=$#
while [ $# != 0 ]
Expand Down Expand Up @@ -98,16 +98,16 @@ dot() {

if [ $quit -gt 0 ] && ! [ -n "$1" ]; then
if [ $verb -lt 2 ]; then
echo "\n$last"
printf "\n%s\n" "$last"
fi
exit 5
fi
}

info() {
last="$@"
last="$*"
if [ $verb -ge 2 ]; then
echo "$@"
printf "%s\n" "$@"
fi
}

Expand Down

0 comments on commit 04adaa2

Please sign in to comment.