From 17a68f81307e56caeb1133ccfff4d2fa2cd2903d Mon Sep 17 00:00:00 2001 From: Victor Wagner Date: Fri, 30 Oct 2020 14:02:10 +0300 Subject: [PATCH] Make booksort return non-zero if there were unparsable files --- booksort | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/booksort b/booksort index b6d6cff..e966f61 100755 --- a/booksort +++ b/booksort @@ -331,7 +331,7 @@ def handle_file(infilename, needzip=False, move=False, simulate=False, mode="w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) - # strip .zip extnesion from archive member + # strip .zip extnesion from archive member outfile = zipf.open(filename[:-4], mode="w") else: zipf = None @@ -375,6 +375,7 @@ def main(): print("Options --move and --simulate cannod be used together\n", file=sys.stderr) sys.exit(1) + failures = 0 for param in files: try: handle_file(param, **opts) @@ -386,5 +387,10 @@ def main(): if opts["verbose"]: import traceback traceback.print_tb(info[2]) + failures += 1 + if failures: + print("%d file(s) were unparsable" % failures, file=sys.stderr) + sys.exit(2) + if __name__ == "__main__": main()