Skip to content

Commit

Permalink
support for commandline (e.g.: dosh -c 'ls -l' or dosh -s)
Browse files Browse the repository at this point in the history
  • Loading branch information
dealfonso committed Nov 29, 2018
1 parent ecdbc76 commit 034ba41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bin/dosh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
sudo /bin/shell2docker
sudo /bin/shell2docker "$@"
17 changes: 12 additions & 5 deletions src/bin/shell2docker
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,18 @@ else
fi

# Finally we enter in the container
p_debug "executing: docker exec -it" "$CONTAINERNAME" "$CONTAINERCOMMAND"
TERMFLAGS=
if [ "$TERM" != "dumb" -a "$TERM" != "unknown" ]; then
p_debug "need to allocate terminal because TERM=$TERM"
TERMFLAGS=-t
fi

CONTAINERCOMMAND=( "$CONTAINERCOMMAND" "$@" )
if [ "$RUNCOMMANDS" == "true" ]; then
callscripts preexec "$CONTAINERNAME" "$CONTAINERCOMMAND"
docker exec -it "$CONTAINERNAME" "$CONTAINERCOMMAND"
callscripts exec "$CONTAINERNAME" "$CONTAINERCOMMAND"
callscripts preexec "$CONTAINERNAME" "${CONTAINERCOMMAND[@]}"
p_debug "executing: docker exec $TERMFLAGS $CONTAINERNAME ${CONTAINERCOMMAND[@]}"
docker exec -i $TERMFLAGS "$CONTAINERNAME" "${CONTAINERCOMMAND[@]}"
callscripts exec "$CONTAINERNAME" "${CONTAINERCOMMAND[@]}"
else
p_info "docker commands are not being run because of configuration (var RUNCOMMANDS is not set to true)"
fi
fi
2 changes: 1 addition & 1 deletion src/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1-2
0.2-1

0 comments on commit 034ba41

Please sign in to comment.