-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
single backslash \ at end of line could be disallowed within $'...' (and maybe others) #1825
Comments
It seems to be adding a backslash:
Similar to here:
|
For the first example, I guess I would have expected it to fail with "Invalid char escape" (or print The problem seems to be there is never an "invalid char escape" error, nor an escaped (dropped) newline ( |
It seems like this is identical to bash behavior
The issue is that all strings in shell are MULTILINE strings. Single quotes, double quotes, etc.
|
What you say does not explain why the single \ is parsed with parse_backslash off. It's also against what happens within double-quotes. There the newline (and the backslash before it) gets consumed, and no "Invalid char escape" is necessary:
Consuming is consistent with shell:
Plus python seems parsing single backslashes in singe- and double-quotes just fine, and there is still a multifold of ways remaining to denote the same string using \b. This makes me ask how well backed up and necessary is the breaking behavior? And maybe it does make sense, to rather improve uniqueness of denoting strings with a strict_ option forbidding singelton-backslash-pairs -- instead of singleton-backslashes -- to maintain compatibility with shell and python. |
Oh I see! Yeah actually that is a good point. We want backslashes to always be doubled so there is one way of writing it I'm not sure why it is the way it is |
If $'foo\z' is illegal, then this should be too: $'foo\ line2 ' The sequence \\ \n was a special case in _C_STRING_COMMON, giving Id.Char_Literals. I moved it down to lex_mode_e.SQ_C, and made it Id.Unknown_Backslash, which means: - It's literal in OSH (when parse_backslash is on) - It's a syntax error in YSH (when parse_backslash is off) This is issue #1825.
This is fixed - we now consistently disallow the single backslash then newline in YSH (details in commit description) Will be out with the next release Great testing, thank you! |
Is it ok to pass the backslash (consumed by command line parsing?) on to the string literal, and it becoming a literal \ even though parse_backslash is off?
And this is a non-identical variation that is printing the same:
The text was updated successfully, but these errors were encountered: