Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Commit

Permalink
fix shellcheck findings based on eficode/pull/16
Browse files Browse the repository at this point in the history
  • Loading branch information
Okeanos committed Apr 2, 2020
1 parent 1a041d7 commit b004b8e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions wait-for
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ usage() {
exitcode="$1"
cat << USAGE >&2
Usage:
$(basename $0) [host:port...] [-t timeout] [-- command args]
$(basename "$0") [host:port...] [-t timeout] [-- command args]
-q | --quiet Do not output any status messages
-l | --loose Execute subcommand even if the test times out
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
Expand All @@ -54,15 +54,15 @@ test_connection() {

wait_for() {
local result
for i in `seq $TIMEOUT` ; do
for _ in $(seq $TIMEOUT) ; do
# use a 1-second timeout, but still sleep 0.1 seconds after just to be safe
test_connection "$1" "$2"
result=$?
if [ $result -eq 0 ] ; then break ; fi
sleep 1
done
[ $result -ne 0 ] && echoerr "Operation timed out waiting for $1:$2"
if [ $result -eq 0 -o $LOOSE -eq 1 -a $# -gt 0 ] ; then
if [ $result -eq 0 ] || [ $LOOSE -eq 1 ] && [ $# -gt 0 ] ; then
TIMEOUT=$OLD_TIMEOUT QUIET=$OLD_QUIET PORT=$OLD_PORT HOST=$OLD_HOST LOOSE=$OLD_LOOSE exec "$@"
fi
exit $result
Expand Down Expand Up @@ -117,7 +117,7 @@ for SERVICE in ${SERVICES} ; do
HOST=$(printf "%s\n" "$SERVICE"| cut -d : -f 1)
PORT=$(printf "%s\n" "$SERVICE"| cut -d : -f 2)

if [ "$HOST" = "" -o "$PORT" = "" ]; then
if [ "$HOST" = "" ] || [ "$PORT" = "" ]; then
echoerr "Error: you need to provide a host and port to test."
usage 2
fi
Expand Down

0 comments on commit b004b8e

Please sign in to comment.