Julia: run(``): BoundsError

Created on 25 Oct 2016  ·  7Comments  ·  Source: JuliaLang/julia

julia> run(``)
ERROR: BoundsError: attempt to access 0-element Array{String,1} at index [1]
 in #414 at .\process.jl:478 [inlined]
 in setup_stdio(::Base.##414#415{Cmd,Ptr{Void},Base.Process}, ::Tuple{RawFD,RawFD,RawFD}) at .\process.jl:466
 in #spawn#413(::Nullable{Base.ProcessChain}, ::Function, ::Cmd, ::Tuple{RawFD,RawFD,RawFD}, ::Bool, ::Bool) at .\process.jl:477
 in run(::Cmd) at .\process.jl:591
Hacktoberfest error handling good first issue help wanted

Most helpful comment

We can leave it as up for grabs. Should be as simple as checking for emptiness of a command before trying to spawn it and raising a specific error.

All 7 comments

I'm not exactly sure what you expected this to do?

I guess we could give a somewhat better error message.

Why would this error? You aren't doing anything, I'd expect it to run silently and run nothing.

Because it should represent a single command, not zero or more than one.

It also seems like one could accidentally generate an empty command and it's better to raise an error in that case instead of silently ignoring causing problems in other cases by default. If you have a use case that wants this to not error, you can easily overwrite the default behavior by checking if the command is empty.

Fair point, I think then Stefan has a good suggestion at possibly emitting a better error message, but feel free to close.

FWIW I tried this out with master, 0.5, 0.4, and 0.3 to see what the past behavior has been. As it turns out, the behavior in 0.3 was, at least IMHO, the best: It errors saying that there are too few arguments to the command. I think that's much clearer than the behavior on 0.4+.

We can leave it as up for grabs. Should be as simple as checking for emptiness of a command before trying to spawn it and raising a specific error.

Was this page helpful?
0 / 5 - 0 ratings