Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix ENV variables to avoid clashes #13

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions wait-for
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh

TIMEOUT=15
QUIET=0
WAITFOR_TIMEOUT=15
WAITFOR_QUIET=0

echoerr() {
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
if [ "$WAITFOR_QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
}

usage() {
Expand All @@ -20,9 +20,9 @@ USAGE
}

wait_for() {
for i in `seq $TIMEOUT` ; do
nc -z "$HOST" "$PORT" > /dev/null 2>&1
for i in `seq $WAITFOR_TIMEOUT` ; do
nc -z "$WAITFOR_HOST" "$WAITFOR_PORT" > /dev/null 2>&1

result=$?
if [ $result -eq 0 ] ; then
if [ $# -gt 0 ] ; then
Expand All @@ -40,21 +40,21 @@ while [ $# -gt 0 ]
do
case "$1" in
*:* )
HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
WAITFOR_HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
WAITFOR_PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
shift 1
;;
-q | --quiet)
QUIET=1
WAITFOR_QUIET=1
shift 1
;;
-t)
TIMEOUT="$2"
if [ "$TIMEOUT" = "" ]; then break; fi
WAITFOR_TIMEOUT="$2"
if [ "$WAITFOR_TIMEOUT" = "" ]; then break; fi
shift 2
;;
--timeout=*)
TIMEOUT="${1#*=}"
WAITFOR_TIMEOUT="${1#*=}"
shift 1
;;
--)
Expand All @@ -71,7 +71,7 @@ do
esac
done

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