MCPcopy Index your code
hub / github.com/docker/docker-agent / isInteractive

Function isInteractive

pkg/selfupdate/selfupdate.go:636–642  ·  view source on GitHub ↗

isInteractive reports whether stdin is a terminal we can prompt on. It probes for an Fd() accessor (satisfied by *os.File and by common wrappers) rather than asserting a concrete *os.File, so a wrapped real terminal is still detected. A reader without a file descriptor (e.g. a bytes buffer in tests)

(stdin io.Reader)

Source from the content-addressed store, hash-verified

634// detected. A reader without a file descriptor (e.g. a bytes buffer in tests)
635// or a non-terminal descriptor (pipe, redirect, CI) is non-interactive.
636func isInteractive(stdin io.Reader) bool {
637 f, ok := stdin.(interface{ Fd() uintptr })
638 if !ok {
639 return false
640 }
641 return isatty.IsTerminal(f.Fd()) || isatty.IsCygwinTerminal(f.Fd())
642}
643
644// selfUpdateEnv returns environ with every DOCKER_AGENT_SELF_UPDATE_* entry
645// removed so the caller can append fresh markers without leaving duplicates.

Callers 1

confirmUpdateFunction · 0.85

Calls 1

IsTerminalMethod · 0.80

Tested by

no test coverage detected