epubcheck exit code

36 views
Skip to first unread message

jens.t...@gmail.com

unread,
May 4, 2015, 11:24:56 AM5/4/15
to epub...@googlegroups.com
Hello,

It seems as if epubcheck always exits with a code of 0, which makes it difficult to detect WARNING or ERROR in a script (other than parsing its output). Is there a way to return different exit codes, depending on the success level of an epubcheck run?

Or am I missing something?

Thanks!
Jens

Ori Idan

unread,
May 4, 2015, 2:37:09 PM5/4/15
to epub...@googlegroups.com
I think the return code is the Java return code and not the epubcheck return code, so I wonder if it is possible.


-- 
Ori Idan CEO Helicon Books




--
You received this message because you are subscribed to the Google Groups "epubcheck" group.
To unsubscribe from this group and stop receiving emails from it, send an email to epubcheck+...@googlegroups.com.
To post to this group, send email to epub...@googlegroups.com.
Visit this group at http://groups.google.com/group/epubcheck.
For more options, visit https://groups.google.com/d/optout.

jens.t...@gmail.com

unread,
May 4, 2015, 2:46:21 PM5/4/15
to epub...@googlegroups.com
Disclaimer: I have not looked at the epubcheck source code (yet) :-)

Calling lang.exit() should provide sufficient means to communicate an exit code from epubcheck to the caller (e.g. terminal or script).

Ric Wright

unread,
May 4, 2015, 3:13:37 PM5/4/15
to epub...@googlegroups.com
It is probably possible, but normally the exit code is supposed to indicate whether the app executed properly (or not).  Using that return code to indicate one of a myriad of possible outcomes seems somewhat convoluted.  Much more flexible to simply parse (I.e. Grep) the output, IMO.

Ric


--

jens.t...@gmail.com

unread,
May 4, 2015, 4:39:12 PM5/4/15
to epub...@googlegroups.com
I guess that's open to debate, and I was just curious about whether epubcheck implements exit codes. It looks to me as if epubcheck exits with a 0 when it ran successfully, and a failing ebook validation is still a successful run. 

Take a compiler, for example. A compiler runs successfully even though the input program might fail to compile; in that case, the compiler exists with a non-0 exit code which is used by Makefiles to detect breakage. Command-line options control whether or not a compiler should exit with a non-0 upon warnings or errors.

Similarly, I would argue that it's simpler to check the return code of epubcheck rather than scanning its output. Scanning is always flakey because it assumes that the output follows a certain format (which can change). Perhaps it would make sense to add command-line options to epubcheck as well?

Jens

Tobias Fischer

unread,
May 4, 2015, 4:56:00 PM5/4/15
to epub...@googlegroups.com
epubcheck 3.0.1 exits with 1 if errors and/or warnings occure and with 0 if the epub is valid.
See here: https://github.com/IDPF/epubcheck/blob/v3.0.1/src/main/java/com/adobe/epubcheck/tool/Checker.java#L182 and following.

And so does current epubcheck 4.0 alpha:
https://github.com/IDPF/epubcheck/blob/94220fee5cb4cb2f5c9e66cad2299216c3f86fb9/src/main/java/com/adobe/epubcheck/tool/Checker.java#L31

I can reproduce the correct behaviour on my mac with some testcases.

Please open a ticket in the issue tracker if you feel like we should add other exit codes for e.g. only warnings / only errors / etc...

Cheers,
Tobias


Am 04.05.15 um 17:24 schrieb jens.t...@gmail.com:

jens.t...@gmail.com

unread,
May 4, 2015, 5:17:10 PM5/4/15
to epub...@googlegroups.com
Tobias, 

You are correct, and this is all my fault :) I ran epubcheck | grep and was testing the exit code of grep. Using bash's ${PIPESTATUS[0]} I see the exit code 1 from epubcheck.

Still, can I adjust to exit-1 for warning and/or error?

Jens

Tobias Fischer

unread,
May 5, 2015, 4:16:19 PM5/5/15
to epub...@googlegroups.com
Okay.


Still, can I adjust to exit-1 for warning and/or error?
Not at the moment. But you can create a PullRequest or open an issue in our github issue tracker.

The return value is currently (epubcheck 4.0 alpha) handled in the processFile() method in
https://github.com/IDPF/epubcheck/blob/94220fee5cb4cb2f5c9e66cad2299216c3f86fb9/src/main/java/com/adobe/epubcheck/tool/EpubChecker.java#L397
and following.

Cheers,
Tobias


Am 04.05.15 um 23:17 schrieb jens.t...@gmail.com:
--
Reply all
Reply to author
Forward
0 new messages