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

Before Julia 0.5, I could run

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

      

and get the difference between the files.

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

What is the intended way to solve this problem?

+3


source to share


1 answer


diff = readlines(Cmd(`diff $oldfile $newfile`, ignorestatus=true))

      



+6


source







All Articles