Better support for running external commands

,

You can do this by quoting the command with single or double backticks.

This is because globs (e.g. * to match any string) don’t work in Julia (yet).

This only matches a path with the literal name *, which is probably not what you want.

It does what you ask it to, it escapes && as an argument to echo. && for command chaining, like in bash, is also not currently supported.

This is actually a feature, because it protects you from command injection. You usually don’t just want to run arbitrary strings as commands. If you really want to create a command from a string like this, you need to call Base.shell_parse directly, but this could definitely be documented better.

I do agree that there are still a lot of ways running external commands could be improved. To me, that would mean moving Glob.jl into base, supporting piping and chaining constructs like |, >, &&, etc. directly in command literals, and I’d also really like to see parse command interpolations at parse time · Issue #3150 · JuliaLang/julia · GitHub being addressed.

6 Likes