Mercurial > dottes
diff abcfield.py @ 584:696c461c8dc0
Set exit status on abcfield.py to indicate if anything found.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Sat, 29 Oct 2016 23:18:45 +0100 |
parents | 760d0ae5acea |
children | daa3b76bd11f |
line wrap: on
line diff
--- a/abcfield.py Sat Oct 29 21:51:59 2016 +0100 +++ b/abcfield.py Sat Oct 29 23:18:45 2016 +0100 @@ -130,6 +130,7 @@ 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 @@ 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))