Repository navigation
echo: don't expand \u, \U and \" in -e - #14475
Merged
Merged
Conversation
|
GNU testsuite comparison: |
GNU's echo recognizes only \a \b \c \e \f \n \r \t \v \\ \0NNN \NNN and \xHH after -e. uucore's escape parser is shared with printf, which also recognizes \", \uHHHH and \UHHHHHHHH, so echo -e picked those up as well: echo -e '\u0041' printed A instead of \u0041. Add an EscapeSet parameter alongside the existing OctalParsing one, and have echo ask for the set without \", \u and \U. Those three then fall through to the unknown-escape arm and are emitted verbatim, backslash included, which is what GNU does. printf keeps the full set on both its format-string and %b paths.
SichenLiang
force-pushed
the
echo-no-unicode-escapes
branch
from
September 9, 2026 12:45
0cbc779 to
ff1614b
Compare
Contributor
|
Thanks! |
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.
uutils'
echo -eexpands\u,\Uand\". GNU'sechohas none of the three andprints them as written. Our own
--helpalready lists only the sequences GNU has:so the implementation is the outlier here, not the documentation.
Malformed forms were losing text as well, since
parse_unicodeconsumes its digitwindow before validating it:
printfkeeps all three, on its format string and on%b, and is byte identicalbefore and after across the escapes I tested, exit status and stderr included.
Measured against GNU coreutils 9.11,
LC_ALL=C.This touches
escape.rs,mod.rsandecho.rs, which #14406 also edits. A trial mergegives five mechanical conflict hunks and no semantic disagreement, so whichever lands
first the other is a small re-resolve.
Fixes #14414