Skip to content

Improve handling of parameters in @-files: add quote-handling for whitespaces in parameters. - #931

Open
kfriedberger wants to merge 3 commits into
google:masterfrom
kfriedberger:master
Open

kfriedberger wants to merge 3 commits into
google:masterfrom
kfriedberger:master

Conversation

@kfriedberger

Copy link
Copy Markdown

And abort on recursive include of @-files.

…taining whitespace.

Parameters from @-files are no longer simply split at whitespace,
but now recognize quotes (single or double quotes allowed),
such that parameters can contain whitespace that are kept unmodified.

Each parameter can be written as either a quoted string (single or double quotes are allowed) or a plain unquoted string.
Surrounding quotes are removed from parameters when parsing.
It is possible to have double quotes within a single-quoted string and vice-versa.
Such internal quotes remain untouched when parsing.
For simplicity, we do not handle escaped quotes.
We do not enforce an ending quote in @-files
and simply close the string on end-fo-file.
This might be nicer for the user and does not harm.
@baierd

baierd commented Apr 24, 2023

Copy link
Copy Markdown

Would it be possible to merge this? I am effected by this issue on my Windows machine.

abashev pushed a commit to openjavaformat/open-java-format that referenced this pull request Sep 23, 2026
…cludes itself

CommandLineOptionsParser split an @argfile at every whitespace character
and knew no quotes, so a path with a space in it became several
arguments. Each was reported as "Skipping non-Java file", and the run
still exited 0 (#40, from google/google-java-format#421). A parameter
file that included itself recursed until the stack overflowed.

This ports google/google-java-format#931 by Karlheinz Friedberger, its
three commits squashed into one. An argument in a parameter file may be
quoted with double or single quotes and then keeps its whitespace; an
unclosed quote runs to the end of the file; and a file that is already
being read is reported as "parameter file was included recursively".
Escaped quotes are not handled, as upstream. The three
CommandLineOptionsParserTest cases come from that PR.
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.

2 participants