Skip to content

diff: decode escapes in --palette values - #383

Open
binhvq wants to merge 3 commits into
uutils:mainfrom
binhvq:palette-decode-escapes
Open

binhvq wants to merge 3 commits into
uutils:mainfrom
binhvq:palette-decode-escapes

Conversation

@binhvq

@binhvq binhvq commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #362.

--palette values were copied as is, so --palette='ad=\061;32' put a literal \061 in the output, and \: ended the value.

Values are now decoded the way GNU diff 3.12 does it:

  • \NNN octal and \xHH hex (any number of digits, low byte kept), \a \b \e \f \n \r \t \v, \? for DEL, \_ for space; any other escaped character stands for itself, so \: and \\ work
  • ^X caret notation for @ to ~, and ^? for DEL
  • a value ending in \ or ^, or ^ followed by something else, is rejected with the same two messages as GNU (unrecognized prefix: ad, unparsable value for --palette)

The palette entries are bytes now, since a value can decode to anything.

One difference left on purpose: for ^? GNU prints DEL followed by a stray ?, which looks like a bug there. This prints DEL only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diff - --palette values are used verbatim; backslash escapes are not decoded

1 participant