Commit 5f71029e authored by Fred Drake's avatar Fred Drake

err_exit():  Allow the return code to be passed in, with a default of 2
    (the usual Unix return code for command-line errors).

main():  Remove the try/except that caused a second err_exit() call after
    the first call to sys.exit().  The try/except also prevented the
    first sys.exit() from actually doing so (only the second, unintended
    call caused the script to exit).

    When the users *asks* for help (-h), use a return code of 0 since
    there was not an error that triggered the help message.
parent e45b6896
......@@ -158,25 +158,21 @@ def main(args):
filename=None
test_all=None
try:
options, arg=getopt.getopt(args, 'ahd:f:')
if not options:
err_exit(usage_msg)
for name, value in options:
name=name[1:]
if name == 'a':
test_all=1
elif name == 'd':
pathname=string.strip(value)
elif name == 'f':
filename=string.strip(value)
elif name == 'h':
err_exit(usage_msg)
else:
err_exit(usage_msg)
except:
options, arg=getopt.getopt(args, 'ahd:f:')
if not options:
err_exit(usage_msg)
for name, value in options:
name=name[1:]
if name == 'a':
test_all=1
elif name == 'd':
pathname=string.strip(value)
elif name == 'f':
filename=string.strip(value)
elif name == 'h':
err_exit(usage_msg, 0)
else:
err_exit(usage_msg)
testrunner=TestRunner(os.getcwd())
if test_all:
......@@ -188,9 +184,9 @@ def main(args):
sys.exit(0)
def err_exit(message):
def err_exit(message, rc=2):
sys.stderr.write("\n%s\n" % message)
sys.exit(1)
sys.exit(rc)
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment