Repository navigation
fix(prompt): strip \[ \] ignore-markers on every PS1 render path - #480
Merged
Merged
Conversation
#431) wt70 stripped the prompt-ignore markers only at the piped -i driver's terminal write. The remaining render consumers still emitted the markers unstripped: - Shell::expand_prompt_string / expand_prompt_string_mut (the host line-editor channel niubash's BashPrompt renders through) - the ${var@P} prompt transform (parameter_transforms), which leaked the raw \x01/\x02 bytes to stdout Both now funnel through prompt_expansion::strip_prompt_ignore_markers (readline display.c expand_prompt assembles the display without the width-accounting delimiters), and the driver-side filter is folded into that shared boundary. ESC and other real control bytes are untouched, so color and cursor-positioning geometry survive. Regressions pin the inretio theme shape (marker bytes and literal \\[ \\] absent, ESC[01;32m present), a bash-it PROMPT_COMMAND + command-substitution shape (0 fragments across the stream), the host channel, and ${PS1@P}. closes #431
caomengxuan666
added a commit
that referenced
this pull request
Oct 10, 2026
…els strip the ignore markers (rubash#431 scope fix) #480 funneled the ${var@P} prompt transform through strip_prompt_ignore_markers alongside the render channels. For a PS1 the strip is display semantics (readline display.c expand_prompt assembles the prompt without the width-accounting bytes), but a script-visible transform result must keep bytes that were IN the value: upstream bash-tests exp8.sub:26 runs `recho ${var@P}` against var=$'x\001y\177z' and GNU 5.3.0 records `argv[1] = <x^Ay^?z>` in exp.right:253 — the literal \x01 survives. %q probes on WSL GNU 5.3.0 and Git 5.2.37 agree ($'x\001y\177z'). The strip ate the literal byte (`xy^?z`), a GNU-parity regression that the exp suite-slice snapshot pinned as a CI failure — the red 'GNU regression goldens and canaries' job every PR inherited since #480 was exactly this one byte. ${var@P} is decode_prompt_string and nothing else again: - the \`\\[\\]\` markers are already handled per GNU parse.y:6609-6622 inside decode_prompt_string (dropped when no line editor is active, marker bytes when emacs/vi is on) — the prompt_transform_strips_ ignore_markers regression stays green on that branch, not on a strip; - the render channels (expand_prompt_string{,_mut}, the piped -i driver) keep their strip: a terminal-bound prompt must not carry the width-accounting bytes. niubash's BashPrompt bridge is unaffected. Gate: issue431 regressions 4/4, parameter-transform tests green, full regression suite 26/27 locally (the snapshot leg is the OS-dependent comsub slice this machine cannot reproduce; the CI artifact from the previous commit proves the runner records the committed bytes for all 13 slices once this revert lands).
caomengxuan666
added a commit
that referenced
this pull request
Oct 10, 2026
…ot env + CI golden-refresh artifact (#496) * tests/regression: airtight env for suite snapshots + CI golden-refresh artifact (drift protocol) The 'GNU regression goldens and canaries' job has been red on every PR since 10ff8a3 (#480): the ${var@P} marker-strip fix (#431) legitimately changed the exp slice's stdout, and tests/regression/snapshots/exp.snap was never re-recorded — every later PR inherited that red (26 passed / 1 failed, upstream_suite_slice_snapshots). Two structural fixes so a stale baseline cannot snowball again: 1. run_suite_snapshot now runs the suites in the same airtight environment as the goldens (env_clear + machine-infrastructure whitelist + PATH/HOME), instead of only removing OLDPWD/BASH_ENV/ WINUXSH_ROOT. The old ambient-env pass-through made snapshot bytes machine-dependent: exp.tests:416 executes `${THIS_SH} -c ...`, so any shell that exports THIS_SH records argv lines a clean runner never emits, and shell-option variables (BASHOPTS/SHELLOPTS/POSIXLY_CORRECT classes) are exactly what the alias-expansion machinery keys on. A snapshot byte that depends on ambient env cannot be a baseline. 2. The regression job records the snapshots on the runner and uploads them as the regression-snapshots artifact (always()). When the comparison fails because committed .snap files are stale, that artifact is the runner-true replacement content — no more hand-transcribing the truncated 40-line panic window. Module header documents the re-record protocol: a snapshot diff IS a semantic change; a recording commit must cite the behavior-fix issue/PR per slice, or the red baseline ships itself forward. Gate: cargo fmt clean; snapshot suites byte-identical on the recording path; full regression suite green modulo the stale exp.snap this PR re-records next. * fix(prompt): ${var@P} keeps literal control bytes — only render channels strip the ignore markers (rubash#431 scope fix) #480 funneled the ${var@P} prompt transform through strip_prompt_ignore_markers alongside the render channels. For a PS1 the strip is display semantics (readline display.c expand_prompt assembles the prompt without the width-accounting bytes), but a script-visible transform result must keep bytes that were IN the value: upstream bash-tests exp8.sub:26 runs `recho ${var@P}` against var=$'x\001y\177z' and GNU 5.3.0 records `argv[1] = <x^Ay^?z>` in exp.right:253 — the literal \x01 survives. %q probes on WSL GNU 5.3.0 and Git 5.2.37 agree ($'x\001y\177z'). The strip ate the literal byte (`xy^?z`), a GNU-parity regression that the exp suite-slice snapshot pinned as a CI failure — the red 'GNU regression goldens and canaries' job every PR inherited since #480 was exactly this one byte. ${var@P} is decode_prompt_string and nothing else again: - the \`\\[\\]\` markers are already handled per GNU parse.y:6609-6622 inside decode_prompt_string (dropped when no line editor is active, marker bytes when emacs/vi is on) — the prompt_transform_strips_ ignore_markers regression stays green on that branch, not on a strip; - the render channels (expand_prompt_string{,_mut}, the piped -i driver) keep their strip: a terminal-bound prompt must not carry the width-accounting bytes. niubash's BashPrompt bridge is unaffected. Gate: issue431 regressions 4/4, parameter-transform tests green, full regression suite 26/27 locally (the snapshot leg is the OS-dependent comsub slice this machine cannot reproduce; the CI artifact from the previous commit proves the runner records the committed bytes for all 13 slices once this revert lands).
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.
closes #431
Problem
PS1\[/\]ignore-markers rendered as literal text (or leaked as raw\x01/\x02bytes) in some render paths: the oh-my-bash inretio theme shape, and bash-it themes leaking up to 4 marker fragments. wt70's fix stripped the markers only at the piped-idriver's terminal write; the remaining consumers still emitted them unstripped.Root cause
Three consumers turn a PS1 into renderable text; only one stripped the
RL_PROMPT_START/END_IGNOREequivalents:-idriver terminal write (script_driver.rs) — already covered by wt70Shell::expand_prompt_string/expand_prompt_string_mut— the host line-editor channel niubash's BashPrompt renders through — unstripped${var@P}prompt transform (GNU subst.c string_transformP) — leaked the raw\x01/\x02bytes to stdout — unstrippedFix
prompt_expansion::strip_prompt_ignore_markers(readline display.c expand_prompt: the markers are width-accounting delimiters, never display payload).expand_prompt_string,expand_prompt_string_mutand the@Ptransform all strip; the driver-side filter is folded into that boundary.Tests
New
tests/issue431_prompt_marker_render_regressions.rs:\[/\],ESC[01;32mpreservedexpand_prompt_string_mut) marker-free${PS1@P}: markers stripped, ESC payload and prompt text intactExisting suites green (prompt family: issue393/421/433, pb10k marker test, 630 lib tests + full integration sweep identical to the master baseline; the handful of pre-existing failures are environment path-mapping issues reproduced on clean master).