Skip to content

cli: --path-encoding=raw|escape for safe plain output (#45 part 1) - #194

Merged
helly25 merged 1 commit into
mainfrom
feat/path-encoding
Jun 28, 2026
Merged

cli: --path-encoding=raw|escape for safe plain output (#45 part 1)#194
helly25 merged 1 commit into
mainfrom
feat/path-encoding

Conversation

@helly25

@helly25 helly25 commented Jun 28, 2026

Copy link
Copy Markdown
Owner

First half of #45. The plain renderer can C-escape path bytes so a newline / control char in a filename can't corrupt the line-oriented -print stream:

  • --path-encoding=escape -> \\, \n, \t, \r, else \xNN; raw (default) is verbatim + find-compatible.
  • Applies to plain only: kNul stays raw (NUL is the separator), kJsonl always JSON-escapes.
  • render::Renderer gains a PathEncoding; run.cc ResolvePathEncoding mirrors ResolveFormat. Self-documented via the globals table + kHelpText (flows to --help/--man/--markdown). render_test covers escape/raw + plain-only.

Verified: 13 cli/render/run tests green; --path-encoding=escape end-to-end turned a tab in a filename into \t. The --exact (FS-native matching) half of #45 is next.

The plain renderer can now C-escape path bytes so a newline or control
character in a filename cannot corrupt the line-oriented -print stream:
--path-encoding=escape turns `\` and control bytes into `\\`, `\n`, `\t`,
`\r`, or `\xNN`; raw (the default) stays verbatim and find-compatible. It
applies to the plain format only -- kNul keeps raw bytes (the NUL is the
separator) and kJsonl always JSON-escapes.

render::Renderer gains a PathEncoding; run.cc ResolvePathEncoding mirrors
ResolveFormat (last wins, raw default) and feeds the implicit-print renderer.
Self-documented via the globals table + kHelpText (so --help/--man/--markdown
list it). render_test covers escape/raw and that it applies only to plain.

The other half of #45 (--exact, filesystem-native matching) remains.
@helly25
helly25 enabled auto-merge (squash) June 28, 2026 13:31
@helly25
helly25 merged commit 6899115 into main Jun 28, 2026
8 checks passed
@helly25
helly25 deleted the feat/path-encoding branch June 28, 2026 13:37
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.

1 participant