Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
Merge pull request #89 from blinkreaction/feature/winpty
Browse files Browse the repository at this point in the history
Use winpty (console) in Babun on Windows
  • Loading branch information
Leonid Makarov committed Mar 7, 2016
2 parents 573594b + dcb45c1 commit 10e8928
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions bin/dsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/<driveletter>/.. instead of /<driveletter>..
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
Expand All @@ -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 && 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
docker exec -it $container_id bash -i
fi
fi
}

Expand Down

0 comments on commit 10e8928

Please sign in to comment.