dssh: run ssh in the background when it's not being run interactively
authorColin P. Mccabe <colin@cmccabe.xyz>
Tue, 29 Nov 2016 23:16:14 +0000 (15:16 -0800)
committerColin P. Mccabe <colin@cmccabe.xyz>
Tue, 29 Nov 2016 23:16:14 +0000 (15:16 -0800)
dssh

diff --git a/dssh b/dssh
index 7540c8b..14dd22c 100755 (executable)
--- a/dssh
+++ b/dssh
@@ -50,10 +50,6 @@ if [ $# -eq 0 ]; then
 else
     RUN_COMMAND="${@}"
 fi
-EXTRA_DOCKER_ARGS=""
-if [ ${ALLOCATE_TTY} -ne 0 ]; then
-    EXTRA_DOCKER_ARGS="${EXTRA_DOCKER_ARGS} -t"
-fi
 
 which docker &>/dev/null || die "docker must be on the PATH."
 
@@ -74,4 +70,9 @@ else
         die "failed to find a docker image named ${DOCKER_IMAGE_NAME}"
 fi
 
-docker exec -i ${EXTRA_DOCKER_ARGS} "${DOCKER_IMAGE_ID}" ${RUN_COMMAND}
+if [ ${ALLOCATE_TTY} == 1 ]; then
+    docker exec -it "${DOCKER_IMAGE_ID}" ${RUN_COMMAND}
+else
+    docker exec -i "${DOCKER_IMAGE_ID}" ${RUN_COMMAND} &
+    wait
+fi