From 4a97e140e201a1f82f4e14359929146eee644c01 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 14 Jan 2016 14:04:19 -0500 Subject: [PATCH 1/2] dsh bash: run docker via winpty to get a tty console in cygwin --- bin/dsh | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/bin/dsh b/bin/dsh index d466e72..5298bc3 100755 --- a/bin/dsh +++ b/bin/dsh @@ -886,25 +886,9 @@ _bash () if is_yml_absent ; then return 2; fi cd $(yml_get_path) - # workaround through vagrant until docker solves the issue with cygwin - if is_windows; then - check_docker_running - local container_name - if [[ "$1" == "" ]]; then - container_name='cli' - else - container_name="$1" - fi - local container_id - container_id=$(get_container_id $container_name); - # Drop /cygdrive prefix if the working directory is opened as /cygdrive//.. instead of /.. - cwd=$(pwd); cwd=${cwd#/cygdrive} - command="cd $cwd && docker exec -it $container_id bash -i"; - vagrant ssh -c "$command" - return - fi - - if ! is_tty ; then + # Interactive shell requires a tty. + # On Windows we assume we run interactively via winpty (console.exe). + if ! (is_tty || is_windows) ; then echo "Interactive bash console in a non-interactive enveronment!? Nope, won't happen." return 1 fi @@ -919,7 +903,12 @@ _bash () fi local container_id container_id=$(get_container_id $container_name) - docker exec -it $container_id bash -i + if is_windows; then + # Workaround - run docker via winpty (console.exe) to get a tty console in cygwin. + console docker exec -it $container_id bash -i + else + docker exec -it $container_id bash -i + fi fi } From dcb45c19c5ffb785fee8af04ba2e507bceffcc88 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Mon, 7 Mar 2016 15:09:48 -0500 Subject: [PATCH 2/2] Check for the winpty (console) binary on Win --- bin/dsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/dsh b/bin/dsh index 5298bc3..9a1021c 100755 --- a/bin/dsh +++ b/bin/dsh @@ -303,7 +303,7 @@ binary_found () return 1; fi - local bpath=$(which $1) + local bpath=$(which $1 2>/dev/null) if [[ "$bpath" != "" ]] && [ -f $(which $1) ]; then return 0 @@ -903,7 +903,7 @@ _bash () fi local container_id container_id=$(get_container_id $container_name) - if is_windows; then + if is_windows && binary_found console; then # Workaround - run docker via winpty (console.exe) to get a tty console in cygwin. console docker exec -it $container_id bash -i else