Repository navigation
fix(prompt): write PS0 expansion to stderr, matching GNU (eval.c:176) - #233
Merged
Merged
Conversation
niu's PS0 pre-exec output went to stdout while GNU bash writes the decoded PS0 string to stderr (eval.c:164-176 fprintf). For redirected pipelines the captured shape differed: `niu 2>/dev/null` kept the PS0 bytes on stdout and `niu > file` captured them, the opposite of GNU. Route the write through a ShellChannel seam (Stdout/Stderr) and emit PS0 on Stderr. The PS1 rendering channel is untouched: prompt rendering still flows through the PromptBackend/reedline editor path, and the existing BashPrompt marker-stripping behavior (a different channel, per prompt.rs) is unchanged. Regression test: bash_ps0_expansion_targets_stderr_and_stdout_stays_clean captures the channel choice non-interactively and asserts the decoded PS0 bytes land on stderr exactly once with stdout clean. Closes #190.
caomengxuan666
added a commit
that referenced
this pull request
Oct 10, 2026
- Delete docs/eco-harvest-resume-wt97b.md: point-in-time lane resume/handoff snapshot; the harvest/test line now runs on GitHub Actions (eco-harvest-ci.yml) and the diagnosis lives in git history. - CHANGELOG: add Unreleased entries for strip (#228), setup help/non-tty banner (#229), bundled niugit/ripgrep/fd + setup detection (#230/#231), PROMPT_COMMAND exit jump (#232), PS0 stderr (#233), bracketed paste (#234). Co-authored-by: docs-audit <[email protected]>
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.
Summary
PS0's decoded expansion was written to stdout; GNU bash writes it to stderr (eval.c:164-176,
fprintf (stderr, ...)). Redirected pipelines observed the opposite shape:niu 2>/dev/nullkept the PS0 bytes,niu > filecaptured them. This aligns the PS0 output channel with GNU.Changes
crates/niubash-runtime/src/shell.rs(run_bash_ps0_preexec): emit the decoded PS0 through a newshell_channel_write(ShellChannel::Stderr, ...)seam instead of raw stdout writes.prompt.rs(a different channel from PS0) is unchanged.bash_ps0_expansion_targets_stderr_and_stdout_stays_clean: non-tty, captures the channel choice via acfg(test)seam and asserts the decoded PS0 bytes land on the stderr channel exactly once with zero stdout-channel writes.Testing
cargo test -p niubash-runtime --lib -- ps0 prompt: 47 passed (includes the new test and the existingbash_ps0_runs_before_interactive_command).cargo test -p niubash-runtime --lib: 383 passed; the only 3 failures are the pre-existing network-dependentplugins::distrosgit-clone tests (verified failing on the unmodified baseline — environment network resets, unrelated).theme_preview_channel(6),issue117_foreign_ps1(5),smoke(13): all green.Closes #190