Skip to content
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

backslash in cmd literal escapes newline #37728

Closed
simeonschaub opened this issue Sep 24, 2020 · 0 comments · Fixed by #40753
Closed

backslash in cmd literal escapes newline #37728

simeonschaub opened this issue Sep 24, 2020 · 0 comments · Fixed by #40753
Labels
parser Language parsing and surface syntax

Comments

@simeonschaub
Copy link
Member

As brought up by @ExpandingMan and @giordano on Slack, the current behavior of \ before a newline in cmd literals is a bit odd:

julia> dump(`foo \
       bar`)
Cmd
  exec: Array{String}((2,))
    1: String "foo"
    2: String "\nbar"
  ignorestatus: Bool false
  flags: UInt32 0x00000000
  env: Nothing nothing
  dir: String ""

# note the whitespace before `bar`
julia> dump(`foo \
           bar`)
Cmd
  exec: Array{String}((3,))
    1: String "foo"
    2: String "\n"
    3: String "bar"
  ignorestatus: Bool false
  flags: UInt32 0x00000000
  env: Nothing nothing
  dir: String ""

julia> dump(```
       foo \
       bar```)
Cmd
  exec: Array{String}((2,))
    1: String "foo"
    2: String "\nbar"
  ignorestatus: Bool false
  flags: UInt32 0x00000000
  env: Nothing nothing
  dir: String ""

We should probably just treat \ as a line continuation character and just ignore it.

@StefanKarpinski StefanKarpinski added the parser Language parsing and surface syntax label Sep 29, 2020
simeonschaub added a commit that referenced this issue May 8, 2021
This allows the use of `\` in front of newlines inside
non-raw/non-custom string or command literals as a line continuation
character, so the following newline is ignored. This way, long strings
without any newlines in them don't have to be written in a single line
or be broken up. I think we might also want to use this to improve the
printing of long strings in the REPL by printing them as multiline
strings, making use of `\` for long lines if necessary, but that can be
discussed separately.

The command literal part is technically breaking, but the current
behavior is probably unintuitive enough that this can be considered a
minor change. For string literals, this should be entirely non-breaking
since a single `\` before a newline currently throws a parsing error.

closes #37728
simeonschaub added a commit that referenced this issue May 8, 2021
This allows the use of `\` in front of newlines inside
non-raw/non-custom string or command literals as a line continuation
character, so the following newline is ignored. This way, long strings
without any newlines in them don't have to be written in a single line
or be broken up. I think we might also want to use this to improve the
printing of long strings in the REPL by printing them as multiline
strings, making use of `\` for long lines if necessary, but that can be
discussed separately.

The command literal part is technically breaking, but the current
behavior is probably unintuitive enough that this can be considered a
minor change. For string literals, this should be entirely non-breaking
since a single `\` before a newline currently throws a parsing error.

closes #37728
simeonschaub added a commit that referenced this issue May 8, 2021
This allows the use of `\` in front of newlines inside
non-raw/non-custom string or command literals as a line continuation
character, so the following newline is ignored. This way, long strings
without any newlines in them don't have to be written in a single line
or be broken up. I think we might also want to use this to improve the
printing of long strings in the REPL by printing them as multiline
strings, making use of `\` for long lines if necessary, but that can be
discussed separately.

The command literal part is technically breaking, but the current
behavior is probably unintuitive enough that this can be considered a
minor change. For string literals, this should be entirely non-breaking
since a single `\` before a newline currently throws a parsing error.

closes #37728
simeonschaub added a commit that referenced this issue May 9, 2021
This allows the use of `\` in front of newlines inside
non-raw/non-custom string or command literals as a line continuation
character, so the following newline is ignored. This way, long strings
without any newlines in them don't have to be written in a single line
or be broken up. I think we might also want to use this to improve the
printing of long strings in the REPL by printing them as multiline
strings, making use of `\` for long lines if necessary, but that can be
discussed separately.

The command literal part is technically breaking, but the current
behavior is probably unintuitive enough that this can be considered a
minor change. For string literals, this should be entirely non-breaking
since a single `\` before a newline currently throws a parsing error.

closes #37728
simeonschaub added a commit that referenced this issue May 29, 2021
This allows the use of `\` in front of newlines inside
non-raw/non-custom string or command literals as a line continuation
character, so the following newline is ignored. This way, long strings
without any newlines in them don't have to be written in a single line
or be broken up. I think we might also want to use this to improve the
printing of long strings in the REPL by printing them as multiline
strings, making use of `\` for long lines if necessary, but that can be
discussed separately.

The command literal part is technically breaking, but the current
behavior is probably unintuitive enough that this can be considered a
minor change. For string literals, this should be entirely non-breaking
since a single `\` before a newline currently throws a parsing error.

closes #37728
vtjnash pushed a commit that referenced this issue Jun 3, 2021
This allows the use of `\` in front of newlines inside
non-raw/non-custom string or command literals as a line continuation
character, so the following newline is ignored. This way, long strings
without any newlines in them don't have to be written in a single line
or be broken up. I think we might also want to use this to improve the
printing of long strings in the REPL by printing them as multiline
strings, making use of `\` for long lines if necessary, but that can be
discussed separately.

The command literal part is technically breaking, but the current
behavior is probably unintuitive enough that this can be considered a
minor change. For string literals, this should be entirely non-breaking
since a single `\` before a newline currently throws a parsing error.

closes #37728
shirodkara pushed a commit to shirodkara/julia that referenced this issue Jun 9, 2021
This allows the use of `\` in front of newlines inside
non-raw/non-custom string or command literals as a line continuation
character, so the following newline is ignored. This way, long strings
without any newlines in them don't have to be written in a single line
or be broken up. I think we might also want to use this to improve the
printing of long strings in the REPL by printing them as multiline
strings, making use of `\` for long lines if necessary, but that can be
discussed separately.

The command literal part is technically breaking, but the current
behavior is probably unintuitive enough that this can be considered a
minor change. For string literals, this should be entirely non-breaking
since a single `\` before a newline currently throws a parsing error.

closes JuliaLang#37728
johanmon pushed a commit to johanmon/julia that referenced this issue Jul 5, 2021
This allows the use of `\` in front of newlines inside
non-raw/non-custom string or command literals as a line continuation
character, so the following newline is ignored. This way, long strings
without any newlines in them don't have to be written in a single line
or be broken up. I think we might also want to use this to improve the
printing of long strings in the REPL by printing them as multiline
strings, making use of `\` for long lines if necessary, but that can be
discussed separately.

The command literal part is technically breaking, but the current
behavior is probably unintuitive enough that this can be considered a
minor change. For string literals, this should be entirely non-breaking
since a single `\` before a newline currently throws a parsing error.

closes JuliaLang#37728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants