ftilmann / latexdiff

Compares two latex files and marks up significant differences between them. Releases on www.ctan.org and mirrors
GNU General Public License v3.0
518 stars 73 forks source link

Don't use `die` when exiting successfully #253

Closed lorenzleutgeb closed 2 years ago

lorenzleutgeb commented 2 years ago

I was very surprised to get non-zero exit codes for these invocations:

> latexdiff-vc --version ; echo $?
This is LATEXDIFF-VC 1.3.1.1
  (c) 2005-2020 F J Tilmann
255
> latexdiff --version ; echo $?
This is LATEXDIFF 1.3.1.1 (Algorithm::Diff 1.15 so, Perl v5.34.0)
  (c) 2004-2020 F J Tilmann
255

It turns out that you use die to print the version string and exit:

https://github.com/ftilmann/latexdiff/blob/af22466ac358e69c3d932a986c1c9ed971b99585/latexdiff-vc#L150

However, die sets a non-zero exit code, indicating an error. When printing the version string is everything that the program should do, then I'd also expect it to exit with an exit code of zero once that's done.

The documentation for die states:

If you need to exit the process with a specific exit code, see exit.

IMO, print followed by exit should be used, like here:

https://github.com/ftilmann/latexdiff/blob/af22466ac358e69c3d932a986c1c9ed971b99585/latexdiff#L490-L491

ftilmann commented 2 years ago

Thanks for reporting. This seems a duplicate of #248 and should be fixed on master (and actually in the very latest release, which was made just after). I will close. Let me know if there is still a problem.

lorenzleutgeb commented 2 years ago

Yes, sorry for duplicating, and thanks for fixing that issue, but as of 2022-01-28 master points at af22466 which I am referring to. It seems that you missed latexdiff-vc. Please fix and/or reopen.