Repository navigation
🐛 fix(bash): preserve prompts across locales - #3663
Merged
Merged
Conversation
gaborbernat
force-pushed
the
fix/bash-prompt-runtime
branch
4 times, most recently
from
November 20, 2026 09:10
9758097 to
6a700b3
Compare
The per-character Bash loop slowed activation as prompts grew and could leave an escape byte inside a multibyte character after a locale change. Escape bytes in one linear pass, with nonprinting boundaries where a legacy decoder could absorb them. Keep both prompt expansion passes escaped, including when promptvars changes after activation. Fixes pypa#3621
The Bash version matrix runs on minimal images without the locale utility. Ask the Python interpreter to validate each locale before running its prompt case.
The prompt redraw expansion used by this locale test starts in Bash 4.4. The version matrix includes older Bash releases, which still run the long-prompt activation case.
A shell function named printf can replace the prompt while the new escape pass runs. Call Bash's builtin so activation keeps the supplied prompt under that shell setup.
gaborbernat
force-pushed
the
fix/bash-prompt-runtime
branch
from
November 20, 2026 10:44
6a700b3 to
fd8c977
Compare
gaborbernat
marked this pull request as ready for review
November 20, 2026 11:37
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.
Bash activation escaped the prompt one character at a time. A later GBK locale could absorb an escape when Bash drew
PS1, allowing prompt text to run in the user's shell. The loop also made activation slow for long prompts (#3621). Bash now escapes the prompt in a single pass and keeps escape bytes separate from preceding multibyte text. This addresses draft advisory ANT-2026-CR2KPIYY.Prompt redraw under a changed locale
Bash decodes prompt escapes and then expands the result when
promptvarsis enabled. The prior Bash branch escaped the two passes, following #3466, but an escape next to non-ASCII prompt text could be read as part of a multibyte character under GBK. The new branch inserts a nonprinting boundary before such an escape. It still escapes both passes whenpromptvarschanges after activation orPS1reaches a child shell.Long prompt activation
The old loop copied the remaining prompt on each iteration. The new bytewise pass avoids that repeated copying. The Bash branch calls
builtin printf, so a shell function cannot replace the prompt text. The Semgrep rule now checks the branch structure without requiring the removed loop.Behavior changes
Bash keeps command substitution syntax in prompt values literal across the tested UTF-8, GBK, and GB18030 locale changes. Long prompts activate without the repeated-copy delay. The Bash branch now needs a working POSIX
awk; it returns an error if that command fails. The zshpsvarbranch remains as introduced for #3466. Source-time parsing of generated activation scripts under GB18030 is addressed separately in ANT-2026-UMMZJBBH.Fixes #3621.
Reported by oss-scanner: ANT-2026-CR2KPIYY and ANT-2026-KNCFNMXA.