Skip to content

Commit

Permalink
fix(command): Restore environment variables before calling exec
Browse files Browse the repository at this point in the history
  • Loading branch information
sd-yip committed Dec 19, 2020
1 parent 526918b commit 9964904
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions wait-for
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh

set -- "$@" -- "$TIMEOUT" "$QUIET" "$HOST" "$PORT" "$result"
TIMEOUT=15
QUIET=0

Expand Down Expand Up @@ -30,7 +31,15 @@ wait_for() {

result=$?
if [ $result -eq 0 ] ; then
if [ $# -gt 0 ] ; then
if [ $# -gt 6 ] ; then
for result in $(seq $(($# - 6))); do
result=$1
shift
set -- "$@" "$result"
done

TIMEOUT=$2 QUIET=$3 HOST=$4 PORT=$5 result=$6
shift 6
exec "$@"
fi
exit 0
Expand All @@ -47,8 +56,7 @@ wait_for() {
exit 1
}

while [ $# -gt 0 ]
do
while :; do
case "$1" in
*:* )
HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
Expand Down

0 comments on commit 9964904

Please sign in to comment.