Fix issue with shell closing on failed docker-env call
This commit is contained in:
parent
047235b341
commit
1493035702
@ -162,17 +162,6 @@ function see() {
|
||||
}
|
||||
|
||||
function docker-env() {
|
||||
function usage() {
|
||||
cat >&2 <<EOS
|
||||
Usage: docker-env [OPTIONS] [--] IMAGE [COMMAND] [ARG...]
|
||||
|
||||
Options:
|
||||
-p <port> Publish a container's port(s) to the host
|
||||
-v <volume> Bind mount a volume
|
||||
EOS
|
||||
exit 1
|
||||
}
|
||||
|
||||
port=
|
||||
workdir=/work_dir
|
||||
volumes=("$(pwd):/work_dir")
|
||||
@ -185,13 +174,17 @@ EOS
|
||||
break
|
||||
;;
|
||||
-p)
|
||||
port=$2
|
||||
port="$2"
|
||||
shift
|
||||
;;
|
||||
-v)
|
||||
volumes+=("$2")
|
||||
shift
|
||||
;;
|
||||
-w)
|
||||
workdir="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
@ -199,14 +192,21 @@ EOS
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
usage
|
||||
break
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
usage
|
||||
cat >&2 <<EOS
|
||||
Usage: docker-env [OPTIONS] [--] IMAGE [COMMAND] [ARG...]
|
||||
|
||||
Options:
|
||||
-p <port> Publish a container's port(s) to the host
|
||||
-v <volume> Bind mount a volume
|
||||
EOS
|
||||
return 1
|
||||
fi
|
||||
|
||||
image="$1"
|
||||
@ -228,7 +228,7 @@ EOS
|
||||
run_command+=" -v $volume"
|
||||
done
|
||||
|
||||
run_command+=" $image $cmd"
|
||||
run_command+=" -w \"$workdir\" $image $cmd"
|
||||
|
||||
eval $run_command
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user