From 639f6f42dfadbd54659a9ddd56e410e763b642c3 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Sat, 29 Oct 2016 23:18:45 +0100 Subject: [PATCH] Set exit status on abcfield.py to indicate if anything found. --- abcfield.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/abcfield.py b/abcfield.py index 15d8ca2..6489096 100755 --- a/abcfield.py +++ b/abcfield.py @@ -130,6 +130,7 @@ def process(inf, options): continue found = True print(convertField(line, options)) + return found parser = optparse.OptionParser(usage="usage: %prog [options] [filename]\n\n" " Extract field data from ABC file.") @@ -148,13 +149,14 @@ parser.add_option("-s", "--starts", dest="starts", metavar="CONTENT") (options, args) = parser.parse_args() +res = False if len(args) > 0: for arg in args: try: inf = open(arg, "r") - process(inf, options) + res = res or process(inf, options) finally: inf.close() else: - process(sys.stdin, options) -sys.exit(0) + res = process(sys.stdin, options) +sys.exit(int(not res))