Set exit status on abcfield.py to indicate if anything found.

This commit is contained in:
Jim Hague 2016-10-29 23:18:45 +01:00
parent 07e6191f9c
commit 639f6f42df
1 changed files with 5 additions and 3 deletions

View File

@ -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))