-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Support $^ escape sequence for newlines. #2606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
doc/manual.asciidoc
Outdated
`$:` :: a colon. (This is only necessary in `build` lines, where a colon | ||
would otherwise terminate the list of outputs.) | ||
|
||
`$^` :: a newline. Inserts '\n' into the resulting string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it named not a $n
, similar to the $:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not so visible when surrounded with an another text, and ^ usually means the beginning like in regular expressions.
Thanks! For this not to cause a lot of confusion in the future I think we should print a warning (or error?) if some uses it without |
Following the regression described in #2616, should these newlines be |
@digit-google That's a good question. I think it depends on the use case. For the scripts like in example |
19eb924
to
6c6587b
Compare
Changed behavior on Windows for consistency, will add '\r\n' instead just '\n'. |
Thank you very much, apart from the latest two nits, this looks good to me. @jhasse , wdyt? |
@digit-google Thanks for review! |
Replace '$^' with the actual newlines.
Straight to use case:
This is required when the build system generates scripts, but trying to make one liners from every script is too bug prone. For example 'set ' in Windows cmd.exe requires delayed expansion when the variable (which is just set) was used in the same line. But writer of the building script could not know such details.
Another case is platforms where scripts can not be converted to oneliners in any way (I have a such use case for OpenVMS dcl).
'$^' currently gives an error (bad escape), so this change should not break the current usage of ninja in any way.