Conversation
clap's DisplayVersion error was rendered via `eprint\!` with the comment "stdout is reserved for data/scripts" — but `--version` output _is_ data that scripts rely on. POSIX convention (and the clap default when it handles parsing itself) is that `--version` goes to stdout. This broke scripts like `version=$(wt --version)` and the devcontainer feature test in the reporter's PR, which had to be updated to `wt --version 2>&1` as a workaround. Closes #2072 Co-Authored-By: Claude <noreply@anthropic.com>
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.
Problem
wt --versionwrote to stderr instead of stdout, breaking scripts likeversion=$(wt --version). The reporter hit this while packaging wt as a devcontainer feature and had to work around it withwt --version 2>&1in a test.The root cause is in
src/help.rs: clap'sDisplayVersionerror was rendered viaeprint\!with the comment "stdout is reserved for data/scripts". But--versionoutput is data that scripts rely on — POSIX convention (and clap's own default when it handles parsing itself) is that--versiongoes to stdout. Only errors and diagnostics go to stderr.Solution
Change
eprint\!toprint\!in theDisplayVersionbranch ofmaybe_handle_help_with_pager, and update the comment to explain the POSIX rationale. No change toDisplayHelp(help text goes through the pager path, which correctly uses stdout when a pager isn't available viashow_help_in_pager).Testing
test_version_goes_to_stdoutintests/integration_tests/help.rsthat asserts stdout contains"wt "and stderr is empty. Verified the test fails against the buggy code and passes with the fix.test_versionsnapshot (tests/snapshots/integration__integration_tests__help__version.snap), which had been capturing the buggy behavior (stdout empty, version on stderr).cargo test --test integration— 1416 passed.cargo clippy --all-targets -- -D warningsandcargo fmt --checkclean.Closes #2072 — automated triage