1
votes

I'd like to run a shell command in Julia with command object. However, when constructing a command, I'd need to construct the args in a string first with some logic, then construct a command out of those args.

The issue I have is, when the string has spaces, the command object automatically put quoted it. Below is the example.

julia> my_str = "--arg1 test --arg2 test --flag1"
"--arg1 test --arg2 test --flag1"

julia> app_name = "test.jl"
"test.jl"

julia> `julia $app_name $my_str`
`julia test.jl '--arg1 test --arg2 test --flag1'`

Is there any workaround for this?

In case this info is needed, I'm in Julia 1.1.0

1

1 Answers

1
votes

Passing a list seems to work instead of constructing a string of arguments. This behavior is explained in this section of Julia docs.

julia> `julia $app_name $(split(my_str))`
`julia test.jl --arg1 test --arg2 test --flag1`