'\n' Is Treated As '\' And 'n'
The following python code env.Command(versionFile, allSrcs + ['.git/index', 'SConstruct'], 'echo '#define ZSIM_BUILDDATE \\''`date`\\''\\\\n#define ZSIM_BUILDVERSION \\''`p
Solution 1:
That's not actually either a python or a C++ question as you are complaining about the behavior of shell quoting (some shells allow escape codes like \n in arguments when you use something like echo -e
though).
So if you want to get a newline in, try producing it in Python already (newline inside of quoted strings will make it into the argument of echo) rather than producing some escape sequence that the shell will not further process.
Solution 2:
Solution 3:
'\\\\n' == '\\' + '\\' + 'n'
You're escaping 2 backslashes, so in the next interpretation it comes down to \\n
.
So just replace \\\\n
with \\n
Post a Comment for "'\n' Is Treated As '\' And 'n'"