Honor stdout and stderr false in Container#exec - #609
Open
tas50 wants to merge 1 commit into
Open
Conversation
Container#exec resolved its stream options with
stdout = options.delete(:stdout) || !detach
stderr = options.delete(:stderr) || !detach
so an explicit false fell through to `!detach` and came back as true. Neither
stream could actually be switched off. The README documented
`container.exec(['date'], stderr: false)` as a way to capture only stdout; it
never did:
stdout=["O\n"] stderr=["E\n"] # stderr: false
Test for the key rather than its truthiness, keeping !detach as the default
when the caller says nothing. Passing detach, or passing nothing, behaves
exactly as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Container#execresolved its stream options withAn explicit
falseis falsy, so it fell through to!detachand came back astrue. Neither stream could be switched off.The README documented
container.exec(["date"], stderr: false)as the way to capture only stdout. It never did:The fix
Test for the key rather than its truthiness, keeping
!detachas the default when the caller says nothing:Verification
Two specs, both confirmed failing before the change:
Both pass after. The existing
#execexamples — default behaviour,detach: true, block streaming, tty — are unchanged, and exec_spec is 11 examples / 0 failures.Compatibility
Passing
detach:, or passing nothing, behaves exactly as before. Only an explicitstdout: false/stderr: falsechanges, and that is the documented behaviour finally working rather than a contract anyone could have depended on.Note on CI
#exec when stdin object is passedfails on this branch, but is pre-existing on master — I confirmed master alone reports5 examples, 1 failurefor that same spec. It is the hijack/attach issue and only reproduces on Docker Desktop; it passes on the Linux runners. CI will also stay red here until #605 lands.