Getting Unwanted Quotes in System Calls


file_name = "$(Pkg.dir())/blah/blah.jl"

file_alias = "julia -L $file_name -e 'main()' --"

println(`alias whatev=$file_alias; meow hello`)

prints out:

`alias "whatev=julia -L /Users/dan/.julia/v0.5/blah/blah.jl -e 'main()' --;" meow hello`


Those quotes around "whatev= ... --;" shouldn’t exist.

Is this a compiler error? Do backticks not like equal signs?

// I know the alias won’t work because it doesn’t have quotes. I just removed them, so that didn’t become the topic of discussion

Using * as a wildcard in backtick commands

The command interpolation syntax is special. See for more details, but in short, a good mental model is that it is geared around safely constructing an array of arguments to pass to an exec-like function. Each white-space delimiter represents a new argument. A string that gets spliced in is taken as one complete token and combined with any adjacent text to create a single argument. This is great for ensuring that you don’t need to worry about escaping quote characters yourself. In fact the ones it prints out are entirely for show!

This also means that it’s not running in a shell. There aren’t any shell built-in syntaxes like ; or >… although there has been interest in supporting more things along these lines. So those symbols are now deprecated in 0.6 so that we can start giving them shell-like meanings in the future.