Repository navigation
fix(prompt): \D{} unknown strftime specs keep the %; unclosed brace formats - #1189
Merged
Merged
Conversation
…ormats (rubash#1099)
Two remaining \D{fmt} divergences vs GNU after the \l/\D{} repairs:
- strftime_subset's fallback arm dropped the % from an unknown
conversion, emitting `x` for `%x`. GNU delegates the format to the
system strftime (parse.y:6390-6425 for \D; printf.def:584-636 for
%()T), and glibc strftime emits an unknown conversion VERBATIM —
percent included. Probe-verified on WSL GNU bash 5.3.20 + glibc:
\D{%N} -> %N, %(%N)T -> %N, strftime("%Q"/"%E") -> %Q/%E.
(The issue's Android-bionic oracle emits `N`; the repo oracle is
WSL glibc, which keeps `%N`.)
- An unclosed \D{fmt run still formats under GNU: the scan at
parse.y:6398-6400 stops at `}` or NUL alike, `c` stays 0 so
add_string does not re-emit `\D`. rubash echoed the literal
`\D{fmt` text instead.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.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.
Fixes #1099
Status on master
PR #1111 already fixed two of the three reported escapes (
\lnow yields the ttyname(0) basename elsetty;\D{}now defaults to%X). One reported case still diverged, plus one adjacent\Dedge found while verifying against parse.y:Root cause & fix
Unknown conversion lost its
%.strftime_subset's fallback arm emitted only the specifier char, based on a claim that glibc drops%for unknown conversions. A direct glibc probe shows the opposite — glibc emits unknown conversions verbatim, percent kept:GNU delegates
\D{fmt}(parse.y:6390-6425) and%(fmt)T(printf.def:584-636) to the system strftime, so WSL GNU bash 5.3.20 prints%Nfor both repros. Note on the issue's expected output: the reporter's oracle was Android, whose bionic strftime emitsN; the repo's canonical oracle is WSL GNU 5.3.x on glibc, which emits%N— this PR matches glibc. Fix: the fallback arm now pushes%plus the specifier char. The same strftime_subset serves\D,%(fmt)T, and HISTTIMEFORMAT rendering, so all three align.Unclosed
\D{fmtstill formats under GNU. parse.y:6398-6400 stops the format run at}or NUL alike;cstays 0 soadd_stringdoes not re-emit the\Dprefix —\D{abcformatsabc. rubash echoed the literal.decode_prompt_date_escapenow formats on either terminator.Before / after
PS1='\l'${PS1@P}ttyttyttyPS1='\D{%N}'%NN%NPS1='\D{}'11:12:4511:12:4011:12:40PS1='x\D'x\Dx\Dx\DPS1='\D{abc'abc\D{abcabcprintf '%(%N)T\n' -1%NN%NTests
tests/issue1099_prompt_escape_edges.rs: 6 cases covering all the above.cargo test --release --test issue1099_prompt_escape_edges: 6/6 green;cargo test --release --test regression: 78/78 green.Generated with Devin