Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions script/tools/ck-docker
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ cmd_exec() {
local docker_flags=()
[ -t 0 ] && [ -t 1 ] && docker_flags+=("-it")

# Auto-detect Python commands and enable unbuffered output for live streaming
local is_python=false
for arg in "$@"; do
if [[ "$arg" == "python" || "$arg" == "python3" || "$arg" == *.py ]]; then
is_python=true
break
fi
done

if [ "$is_python" = true ]; then
docker_flags+=("-e" "PYTHONUNBUFFERED=1")
fi

docker exec "${docker_flags[@]}" "${CONTAINER_NAME}" "$@"
}

Expand Down
13 changes: 11 additions & 2 deletions script/tools/ck-exec
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,18 @@ for arg in "${command_args[@]}"; do
cmd_string="${cmd_string} $(printf '%q' "$arg")"
done

# Auto-detect Python commands and enable unbuffered output for live streaming
env_flags=""
for arg in "${command_args[@]}"; do
if [[ "$arg" == "python" || "$arg" == "python3" || "$arg" == *.py ]]; then
env_flags="-e PYTHONUNBUFFERED=1"
break
fi
done

# Execute command
if [ "$interactive" = true ]; then
docker exec -it -w "${workdir}" "${CONTAINER_NAME}" bash -c "${cmd_string}"
docker exec -it ${env_flags} -w "${workdir}" "${CONTAINER_NAME}" bash -c "${cmd_string}"
else
docker exec -w "${workdir}" "${CONTAINER_NAME}" bash -c "${cmd_string}"
docker exec ${env_flags} -w "${workdir}" "${CONTAINER_NAME}" bash -c "${cmd_string}"
fi