Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I capture the output of an external program that returns a non-zero exit code?

Tags:

julia

Prior to Julia 0.5, I could run

diff = readlines(`diff $oldfile $newfile`)

and get the diff between the files.

Now Julia throws an exception because diff returns exit code 1, so I no longer get the output assigned to my variable.

What is the intended way of working around this problem?

like image 215
reveazure Avatar asked Oct 22 '25 15:10

reveazure


1 Answers

diff = readlines(Cmd(`diff $oldfile $newfile`, ignorestatus=true))
like image 59
Isaiah Norton Avatar answered Oct 25 '25 09:10

Isaiah Norton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!