From 25a81b4ef459761fc044717bd151f4819181389d Mon Sep 17 00:00:00 2001 From: Morten Linderud Date: Sun, 23 Jun 2013 04:15:32 +0200 Subject: [PATCH 1/3] Fixed exit and quit with HyQuitter --- bin/hy | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bin/hy b/bin/hy index 1c19538..e4339e1 100755 --- a/bin/hy +++ b/bin/hy @@ -5,5 +5,22 @@ import sys from hy.cmdline import cmdline_handler +class HyQuitter(object): + def __init__(self, name): + self.name = name + + def __repr__(self): + self.__call__() + + def __call__(self, code=None): + try: + sys.stdin.close() + except: + pass + raise SystemExit(code) + +__builtins__.quit = HyQuitter('quit') +__builtins__.exit = HyQuitter('exit') + if __name__ == '__main__': sys.exit(cmdline_handler("hy", sys.argv)) From 56bae8cc54f7626819bca911d6603f7d224f10f4 Mon Sep 17 00:00:00 2001 From: Morten Linderud Date: Sun, 23 Jun 2013 04:18:22 +0200 Subject: [PATCH 2/3] FIxed Authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index d18f375..92c6c0b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,3 +12,4 @@ * John Jacobsen * rogererens * Thomas Ballinger +* Morten Linderud From e1091afe9449b8c3978a2bafebb61908ef72ceae Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Sat, 22 Jun 2013 22:39:05 -0400 Subject: [PATCH 3/3] fix up the quit message to be wiseass like python's --- bin/hy | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/hy b/bin/hy index e4339e1..3668c54 100755 --- a/bin/hy +++ b/bin/hy @@ -1,7 +1,6 @@ #!/usr/bin/env python import sys - from hy.cmdline import cmdline_handler @@ -10,7 +9,9 @@ class HyQuitter(object): self.name = name def __repr__(self): - self.__call__() + return "Use (%s) or Ctrl-D (i.e. EOF) to exit" % (self.name) + + __str__ = __repr__ def __call__(self, code=None): try: @@ -19,8 +20,10 @@ class HyQuitter(object): pass raise SystemExit(code) + __builtins__.quit = HyQuitter('quit') __builtins__.exit = HyQuitter('exit') + if __name__ == '__main__': sys.exit(cmdline_handler("hy", sys.argv))