Julia: Incorrect handling of escaped space (\ ) in file paths

Created on 16 Dec 2019  路  6Comments  路  Source: JuliaLang/julia

julia> versioninfo()
Julia Version 1.3.0
Commit 46ce4d7933 (2019-11-26 06:09 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.0.0)
  CPU: Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)

It appears that cd() and at least a few other file handling functions can't handle that directories have spaces in their names.

The problem exists on the build above (on MacOS) and I have earlier today experienced equal behaviour on Windows 10 x64;

julia> cd("/Users/user/Virtualbox\ Shared\ Folder/")
ERROR: syntax: invalid escape sequence
Stacktrace:
 [1] top-level scope at REPL[7]:0

This may be an issue with how the tab-completion escapes the directory name, but...the escaping looks good to me. And it is identical to how Bash would have done it in a shell.

Most helpful comment

Best to open a new issue or I can guarantee this will not get addressed.

All 6 comments

issue with how the tab-completion

Fixed by #33816 I believe?

the escaping looks good to me

You need cd("/Users/user/Virtualbox\\ Shared\\ Folder/")

Unless I鈥檓 mistaken you don鈥檛 need backslashes at all: the string already is a single path. You only need to escape spaces in contexts like shell parsing where spaces are used to separate words. That is not the case for the cd function, which takes a single argument.

The problem is the tab completion, which introduces backslashes.

I'm still having problems with, let's say, root (drives) directories in Windows. For instance,

julia> cd("C[TAB]
# Nothing happens, which is OK

julia> cd("C:[TAB]
# (1) Suggestions are listed but from the current working directory!!

julia> cd(C:\[TAB]
# Correct suggestions! Including "Program Files"

julia> cd(C:\P[TAB]

julia> cd(C:\Program
            ^ 
# (2) It forgets to write "\\" which will end in an error if it is not corrected
# It stops in "Promgram" since I have another folder called "Program Files (x86)" which is OK

julia> cd(C:\Program  [TAB]
# (3) Suggestions are listed but from the current working directory!!

julia> cd(C:\Program F[TAB] 
# (4) No suggestions are shown. I think, it is so because I have no folder in my current dir that starts from "F".

On the othe hand imagine that one has another drive D:\\.

julia> cd("D:\\My Documents")
# Current dir is "My Documents"

julia> cd("C:\\Program Files")

julia> cd("C:[TAB]
# (1) Suggestions are listed but from the current working directory, as before

julia> cd("D:[TAB]
# (5) Suggestions are listed but from the previous working directory, which was the last working directory on the drive D:

I enumerated what I consider different bugs. Probably, (1, 3, 4 and 5) are related. Should I start a new issue? I don't find anithing like this opened. Thanks

UPDATE: Maybe is worth to ping @pfitzseb. Sorry if I bother you. And thanks if not and for your work.

Best to open a new issue or I can guarantee this will not get addressed.

Was this page helpful?
0 / 5 - 0 ratings