Getting hold of error status from an external command?

I found the following old thread discussing the same problem. Is this

proc = spawn(pipeline(ignorestatus(cmd)))

still the best way to get hold of the exit code?

I wish these commands (run() etc) had an option to return a proc object instead of throwing an exception.

I do it like this:

julia> cmd = Cmd(`which`; ignorestatus=true)
`which`

julia> t = run(cmd)

?Invalid usage. Type 'WHICH -?' for help

julia> t.exitcode
2
1 Like

Thanks!!! That means that I haven’t found the right documentation or the documentation hasn’t been updated.

See the documentation for Cmd.

Edit: yeah, I’m not seeing where the output of the run function is documented. That probably means that my solution is brittle.

1 Like