fix: expand format placeholder followed by a literal '}'#2060
Conversation
A placeholder immediately followed by a literal '}' (e.g. '{}}' or '{.}}')
was treated as fixed text instead of being expanded. The parser detected the
placeholder pattern but, when the next character was '}', fell through to a
branch that copied the whole sequence verbatim and dropped the trailing '}'.
Remove that branch so the placeholder is always emitted and the following '}'
is handled as ordinary literal text. This affects both --format and --exec,
which share the template parser.
|
What you describe is expected behavior. Currently, "}}" is the way to escape a "}" character, so the "}}" is replaced witha literal "}", and the "{" is unmatched, so not replaced. I haven't looked at this deeply, but I am guessing this is effectively changing the eacape syntax, which would be a breaking change. Such a change should probably have more discussion in an issue before it is merged. |
|
Thanks for taking a look, and fair point, I don't want to quietly change the escaping rules either. Digging into the parser, I think the change is narrower than "changing the escape syntax." The reason I filed it as a bug is consistency of the lone That said, you're right that it's technically a behavior change for |
|
I think the sane thing to do here is maximum munch tokenization, same as most lexers/parsers do. Although IMO |
A format placeholder immediately followed by a literal
}wasn't expanded:fd --format '{}}'emitted a literal{}and dropped the trailing brace instead of producing<path>}. The parser fell through to a literal branch whenever a placeholder was followed by}; removing it lets the}be treated as ordinary literal text like everywhere else. Since--execshares the parser,fd -x echo '{.}}'was affected too.