Skip to content

backslash in cmd literal escapes newline #37728

@simeonschaub

Description

@simeonschaub

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    parserLanguage parsing and surface syntax

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions