Repository navigation
fix(alias): pass alias stdout through so 'wt <alias> | ...' works - #2479
Conversation
Aliases share `execute_shell_command` with hooks and `for-each`, all of which were unconditionally redirecting child stdout onto wt's stderr for deterministic ordering with wt's own progress messages. That ordering guarantee is what hook output needs, but for aliases it makes `wt my-alias | tr …` and similar compositions silently produce no output because the alias body's stdout never reaches the pipe. Threads a `redirect_stdout_to_stderr` flag through `ForegroundStep` and `execute_shell_command`. Hooks and `for-each` keep the merge (`true`); aliases pass it through (`false`). Concurrent alias steps still go through the prefixed-line stderr writer in `output/concurrent.rs` — their gutter rendering inherently belongs on stderr. Closes #2478 Co-Authored-By: Claude <[email protected]>
|
@worktrunk-bot can you do a survey of all the times we redirect child output? |
|
Surveyed every place where Merge child stdout onto stderr (the #2478 pattern)
Child output → log file (background jobs)All deliberate, all logging both streams together so the .log files include interleaved stderr context:
Child output →
|
Problem
wt <alias>writes the alias body's stdout onto wt's stderr instead of stdout, sowt my-alias | tr …(or any other downstream pipe) silently produces no output. Reported in #2478:Root cause is in
src/output/handlers.rs::execute_shell_command, whichCmd::shell(...).stdout(Stdio::from(io::stderr()))for every foreground command. The redirect was originally a hook-only behavior added for deterministic ordering with wt's own stderr "Running …" messages; PR #2089 unified hooks, aliases, andfor-eachonto this shared executor and inherited the redirect uniformly without distinguishing aliases.Solution
Thread a
redirect_stdout_to_stderrbool throughForegroundStepandexecute_shell_command. Hooks (src/commands/hooks.rs) andwt step for-each(src/commands/for_each.rs) keep the merge (true) — their output is decoration around wt's stderr messages, and merging keeps ordering deterministic. Aliases (src/commands/alias.rs) pass through (false) —wt <alias>is a user-defined command and its stdout must remain pipeable.Concurrent alias steps still write through
output/concurrent.rs's prefixed-line stderr consumer — the gutter rendering (build │ BUILD) inherently belongs on stderr, so that path is unchanged.Testing
test_alias_body_writes_to_stdoutintests/integration_tests/step_alias.rs. It runs an alias whose body isecho helloand asserts the output appears on stdout, not stderr. Failed before the fix; passes after.step_aliaspick up the routing change — diffs are limited to lines moving from----- stderr -----to----- stdout -----, which is the user-visible behavior we want. Updated viacargo insta test --accept.wt -y test-output | tr '[:lower:]' '[:upper:]'now printsHELLO.cargo test --test integration(1569 tests) andcargo test --lib --bins(606 tests) pass.Closes #2478 — automated triage