diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2015-01-05 02:33:15 -0500 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2015-01-05 02:33:15 -0500 |
commit | 935eba23579af1d64e56fea38ab981846e127645 (patch) | |
tree | a04a7a70f4a15d153f8b737226ae7b942e07b052 /bin | |
parent | 5d033fbd0aed96770bd6802dbece6df1a5c8540e (diff) | |
download | spack-935eba23579af1d64e56fea38ab981846e127645.tar.gz spack-935eba23579af1d64e56fea38ab981846e127645.tar.bz2 spack-935eba23579af1d64e56fea38ab981846e127645.tar.xz spack-935eba23579af1d64e56fea38ab981846e127645.zip |
Allow commands to return error codes.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/spack | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -103,7 +103,7 @@ if args.insecure: # Try to load the particular command asked for and run it command = spack.cmd.get_command(args.command) try: - command(parser, args) + return_val = command(parser, args) except SpackError, e: if spack.debug: # In debug mode, raise with a full stack trace. @@ -116,3 +116,11 @@ except SpackError, e: except KeyboardInterrupt: sys.stderr.write('\n') tty.die("Keyboard interrupt.") + +# Allow commands to return values if they want to exit with some ohter code. +if return_val is None: + sys.exit(0) +elif isinstance(return_val, int): + sys.exit(return_val) +else: + tty.die("Bad return value from command %s: %s" % (args.command, return_val)) |