1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

handle ctrl-c gracefully

This commit is contained in:
Kelly Brazil
2019-10-25 16:05:34 -07:00
parent 1acc4d6c29
commit 0328e14c7c

View File

@ -5,6 +5,7 @@ Main input module
""" """
import sys import sys
import signal
import json import json
import jc.parsers.df import jc.parsers.df
import jc.parsers.env import jc.parsers.env
@ -53,7 +54,13 @@ def helptext():
print(' ls -al | jc --ls -p\n', file=sys.stderr) print(' ls -al | jc --ls -p\n', file=sys.stderr)
def ctrlc(signum, frame):
exit()
def main(): def main():
signal.signal(signal.SIGINT, ctrlc)
if sys.stdin.isatty(): if sys.stdin.isatty():
print('jc: missing piped data\n', file=sys.stderr) print('jc: missing piped data\n', file=sys.stderr)
helptext() helptext()