Invalid escape sequence

In Windows, the autocomplete (i.e. tab) will add a backslash before any whitespaces.
e.g. If I want to include a file which is in a folder with whitespaces, I get the error below (second line)
Is this expected?
I am not even sure if the tab autocomplete is a Windows or Julia feature (and why the backslash appears).

Notably, the command works just fine if I ‘write’ the folder name by hand without '\ ’ (see last line).

julia> isfile("c:\\temp\\some folder with whitespace\\x.jl")
true

julia> include("C:\\temp\\some\ folder\ with\ whitespace\\x.jl")
ERROR: syntax: invalid escape sequence

julia> include("c:\\temp\\some folder with whitespace\\x.jl")

julia> versioninfo()
Julia Version 0.7.0-beta.0
Commit f41b1ecaec (2018-06-24 01:32 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
  JULIA_BINDIR = C:\Julia-0.7.X\bin\
  JULIA_EDITOR = "C:\Program Files (x86)\Notepad++\notepad++.exe"
  JULIA_HOME = C:\Julia-0.6.X\bin\

julia>
2 Likes

I confirm the same in Linux. I pretty sure the completion is done by Julia. So it looks like a bug.

shell> touch "a b"

julia> include("a\ b")

In this case I have to type a\ [TAB]

Backslash-space is an invalid escape sequence.

julia> "a\ b"
ERROR: syntax: invalid escape sequence

EDIT: It’s easier to find what’s wrong if you provide something close to a MWE. For instance, I used a short file name with one space. And the file has length zero. I neglected to include this:

julia> include("a b")
1 Like

Escape sequences have been changed in v0.7.0.
For the motivation see string literals: disallow backslash before non-escapes

Personally this change has been bugging me too (pun intended).
An easy solution is to use raw strings

julia> raw"C:\temp\some\ folder\ with\ whitespace\x.jl"
"C:\\temp\\some\\ folder\\ with\\ whitespace\\x.jl"
2 Likes