def main(): try: run(sys.argv, sys.stdin, sys.stdout) except EnvironmentError as e: # Workaround for close failed in file object destructor: sys.excepthook is missing lost sys.stderr # http://stackoverflow.com/questions/7955138/addressing-sys-excepthook-error-in-bash-script print >> sys.stderr, str(e) sys.exit(1) except KeyboardInterrupt: sys.exit(1)
def run_integration_test(input, args): input = StringIO(input.strip()) output = StringIO() run(['pawk'] + args, input, output) return output.getvalue().strip()