diff --git a/bin/ophis b/bin/ophis index c368123..f293e4e 100755 --- a/bin/ophis +++ b/bin/ophis @@ -1,10 +1,10 @@ #!/usr/bin/env python from os.path import realpath, dirname, join -from sys import argv, path +from sys import argv, exit, path path.insert(0, join(dirname(realpath(argv[0])), '..', 'src')) import Ophis.Main -Ophis.Main.run_ophis(argv[1:]) +exit(Ophis.Main.run_ophis(argv[1:])) diff --git a/src/Ophis/Macro.py b/src/Ophis/Macro.py index 65b0017..ffd2337 100644 --- a/src/Ophis/Macro.py +++ b/src/Ophis/Macro.py @@ -11,7 +11,6 @@ import sys import Ophis.IR as IR -import Ophis.CmdLine as Cmd import Ophis.Errors as Err macros = {} diff --git a/src/Ophis/Main.py b/src/Ophis/Main.py index 5f93bf4..feedc00 100644 --- a/src/Ophis/Main.py +++ b/src/Ophis/Main.py @@ -20,7 +20,12 @@ import Ophis.Opcodes def run_all(): - "Transforms the source infiles to a binary outfile." + """Transforms the source infiles to a binary outfile. + + Returns a shell-style exit code: 1 if there were errors, 0 if there + were no errors. + + """ Err.count = 0 z = Ophis.Frontend.parse(Ophis.CmdLine.infiles) env = Ophis.Environment.Environment() @@ -69,7 +74,7 @@ def run_all(): if outfile == '-': output = sys.stdout if sys.platform == "win32": - # We can't dump our binary in test mode; that would be + # We can't dump our binary in text mode; that would be # disastrous. So, we'll do some platform-specific # things here to force our stdout to binary mode. import msvcrt @@ -82,10 +87,13 @@ def run_all(): output.flush() if outfile != '-': output.close() + return 0 except IOError: print>>sys.stderr, "Could not write to " + outfile + return 1 else: Err.report() + return 1 def run_ophis(args): @@ -98,8 +106,8 @@ def run_ophis(args): Ophis.Opcodes.opcodes.update(Ophis.Opcodes.c02extensions) Ophis.CorePragmas.reset() - run_all() + return run_all() if __name__ == '__main__': - run_ophis(sys.argv[1:]) + sys.exit(run_ophis(sys.argv[1:])) diff --git a/src/tools/opcodes/gensets.py b/src/tools/opcodes/gensets.py index 84a5991..10ebac7 100755 --- a/src/tools/opcodes/gensets.py +++ b/src/tools/opcodes/gensets.py @@ -142,7 +142,7 @@ def dump_map(m, prologue=''): if __name__ == '__main__': if len(sys.argv) > 1: - chipsets = argv[1:] + chipsets = sys.argv[1:] else: chipsets = ['chipsets.txt'] archs = []