28 lines
701 B
Bash
28 lines
701 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
set -euo pipefail
|
||
|
|
||
|
DOCKER_NAME="ocaml-merlin"
|
||
|
OCAML_BIN_OUT="~/common/images/ocaml-merlin"
|
||
|
|
||
|
# Transforms directories to internal directories for ocaml
|
||
|
function transform_stdin {
|
||
|
sed -e "s!$DIR!/data!g"
|
||
|
}
|
||
|
function transform_stdout {
|
||
|
sed -e "s!/data!$DIR!g" | sed -e "s!/home/opam/.opam/.*/bin!$OCAML_BIN_OUT!g"
|
||
|
}
|
||
|
|
||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
|
||
|
ARGS=${@}
|
||
|
ARGS=$(echo ${ARGS} | transform_stdin)
|
||
|
|
||
|
|
||
|
if [ -t 0 ] ;
|
||
|
then
|
||
|
docker exec -it $NAME ${ARGS} ;
|
||
|
else
|
||
|
# Replace any in-container filenames with host filesnames (stdout + stderr)
|
||
|
{ cat <&0 | transform_stdin | docker exec -i $NAME ${ARGS} 2>&1 1>&3 3>&- | transform_stdout; } 3>&1 1>&2 | transform_stdout
|
||
|
fi
|