Skip to content

bug: The TTY detection identifies /dev/null as a terminal #12

Description

@nabil1440

Blocker: no. This can wait. Do this with the Docker capability.

Defect

  • isInteractive (internal/docker/compose.go:15-18) examines only stdout. It uses os.ModeCharDevice.
  • /dev/null is a character device. Thus, isInteractive returns true for /dev/null. A test gave this result.
  • Cron jobs frequently send output to /dev/null. For these jobs, the CLI does not add -T to docker compose exec.
  • The function does not examine stdin.

Cost

  • With Docker Compose v5.1.1, a cron-style call with stdin and stdout on /dev/null operated correctly. Thus, the effect is small on current Compose versions.
  • The effect on older Compose versions is not known.

Benefit of the fix

  • The CLI identifies a terminal correctly in all conditions.
  • The behavior does not depend on the Compose version.

Fix

Use go-isatty on stdin and stdout. go-isatty is already in the dependency tree.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions