yq
yq copied to clipboard
Fixes #1692 - Inconsistent backslash escaping in literal strings
This is the simplest fix I can come up with for #1692
Before:
% yq -nr eval '"\\"'
\\
After:
% yq -nr eval '"\\"'
\
It does change behaviour. Anyone who is currently using double backslashes in their literal strings will need to change them to quadruple backslashes.
It also makes it possible to use a literal string of a windows path for a filename that starts with n
:
% yq -nr eval '"C:\\tmp\\nigel.xlsx"'
C:\tmp\nigel.xlsx
It may make sense to extract the creation of the string Replacer outside of the stringValue
function and use a single Replacer for all literals instead of a new one each time. I'm not a golang programmer so I don't know what the best way to do that would be.
Can you add some tests for this :)
Closing this till unit tests are added