Improve CLI stdin detection for cross-platform builds#10
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return c.promptToSavePasswordInteractive(reader, password) | ||
| } | ||
|
|
||
| func (c *CLI) stdinIsInteractive() bool { | ||
| interactive, ok := c.detectStdinInteractivity() | ||
| if !ok { | ||
| return false | ||
| } | ||
| return interactive | ||
| } | ||
|
|
||
| func (c *CLI) hasNonInteractiveStdin() bool { | ||
| interactive, ok := c.detectStdinInteractivity() | ||
| if !ok { | ||
| return false | ||
| } | ||
| return !interactive |
There was a problem hiding this comment.
Handle unknown stdin interactivity consistently
If stdinFile.Stat() fails in detectStdinInteractivity both helper methods return false, but they are interpreted in opposite ways: readPasswordFromPipe treats false from hasNonInteractiveStdin as “interactive” and skips reading stdin, while promptToSavePassword treats false from stdinIsInteractive as “non-interactive” and suppresses prompts. On platforms where Stat is unsupported (the scenario this change is meant to cover), piped passwords are silently ignored and the CLI exits with “no password provided” even when input was supplied via a pipe. The error should either be propagated or both helpers should make the same conservative assumption so that piped input is still read.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68f8e564a0dc832cbd8454dba28fd3cf