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)
| 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. |
| 636 | func 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. |
no test coverage detected