From 9964904b5f04538671b064848ad98c675c766ca1 Mon Sep 17 00:00:00 2001 From: Nicholas Yip Date: Thu, 3 Dec 2020 04:00:28 +0900 Subject: [PATCH] fix(command): Restore environment variables before calling `exec` --- wait-for | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wait-for b/wait-for index a8367c7..c542ae4 100755 --- a/wait-for +++ b/wait-for @@ -1,5 +1,6 @@ #!/bin/sh +set -- "$@" -- "$TIMEOUT" "$QUIET" "$HOST" "$PORT" "$result" TIMEOUT=15 QUIET=0 @@ -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 @@ -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)