Mercurial > dottes
changeset 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 | 0206ab9fd6ba |
children | 0a2fc73ba5ec |
files | abcfield.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
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))