From 97f7844853cb64826a23bf9dfe8c2e0359cecea7 Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sun, 30 Aug 2026 00:47:44 +0200 Subject: [PATCH] Fix interactive session check only to restrict TTY --- dockerc | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/dockerc b/dockerc index 709edcd..d7b2af8 100755 --- a/dockerc +++ b/dockerc @@ -1075,19 +1075,10 @@ if [ "$CONTEXT" != '--' ]; then fi -is_interactive_session() +is_tty_session() { - # Non-interactive if explicitly requested via environment variable - if [ "$DEBIAN_FRONTEND" = 'noninteractive' ]; then - return 1 - fi - - # Non-interactive if stdin and/or stdout is not a tty (e.g. piped, redirected, or no tty allocated) - if ! [ -t 0 ] || ! [ -t 1 ]; then - return 1 - fi - - return 0 + # TTY session unless requested otherwise or stdin/stdout are not TTYs + [ "${DEBIAN_FRONTEND}" != 'noninteractive' ] && [ -t 0 ] && [ -t 1 ] } handle_compose_presets_up() @@ -1340,11 +1331,15 @@ handle_compose_presets_run() if [ -n "$COMPOSE_RUN_ENTRYPOINT" ]; then COMPOSE_ARGS="$COMPOSE_ARGS --entrypoint $COMPOSE_RUN_ENTRYPOINT" fi - if [ "$COMPOSE_RUN_INTERACTIVE" = 'true' ] && is_interactive_session; then + if [ "$COMPOSE_RUN_INTERACTIVE" = 'true' ]; then COMPOSE_ARGS="$COMPOSE_ARGS -i" fi - if [ "$COMPOSE_RUN_TTY" = 'true' ] && is_interactive_session; then - COMPOSE_ARGS="$COMPOSE_ARGS -t" + if [ "$COMPOSE_RUN_TTY" = 'true' ]; then + if ! is_tty_session; then + COMPOSE_RUN_TTY='false' + else + COMPOSE_ARGS="$COMPOSE_ARGS -t" + fi fi if [ "$COMPOSE_RUN_SERVICE_PORTS" = 'true' ]; then COMPOSE_ARGS="$COMPOSE_ARGS --service-ports"