Skip to content

Commit

Permalink
use winpty on windows (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin authored Oct 13, 2021
1 parent c31b711 commit 90cf76e
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions sandbox
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ export INDEXER_BRANCH=""
export INDEXER_SHA=""
export INDEXER_DISABLED=""

######################################
# Compatibility with Windows / MSYS2 #
######################################

# All commands that use a TTY/pseudo-TTY
# need to be prefixed by "$WINDOWS_PTY_PREFIX"
WINDOWS_PTY_PREFIX=
if [ "$(uname)" == "Darwin" ]; then
true
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ] || \
[ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
WINDOWS_PTY_PREFIX="winpty"
fi

#########################
# Helpers and utilities #
#########################
Expand Down Expand Up @@ -170,6 +184,15 @@ sandbox () {
docker-compose -f "$SANDBOX_DIR/docker-compose.yml" "$@"
}

# dc is used when a pseudo-TTY is required
# essentially for any interactive command
# like docker-compose exec algod //bin/bash
dc_pty () {
# note: cannot be replaced by $WINDOWS_PTY_PREFIX dc "$@"
# because winpty requires an executable as argument
$WINDOWS_PTY_PREFIX docker-compose -f "$SANDBOX_DIR/docker-compose.yml" "$@"
}

rebuild_if_needed () {
if [ -f "$CLEAN_FILE" ]; then
rm "$CLEAN_FILE"
Expand Down Expand Up @@ -313,17 +336,17 @@ sandbox () {
case $CONTAINER in
algod)
statusline "Entering /bin/bash session in the algod container..."
dc exec algod /bin/bash
dc_pty exec algod //bin/bash
return
;;
indexer)
statusline "Entering /bin/bash session in the indexer container..."
dc exec indexer /bin/bash
dc_pty exec indexer //bin/bash
return
;;
indexer-db)
statusline "Entering /bin/bash session in the indexer-db container..."
dc exec indexer-db /bin/bash
dc_pty exec indexer-db //bin/bash
return
;;
esac
Expand Down

0 comments on commit 90cf76e

Please sign in to comment.