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:
7
jc/jc.py
7
jc/jc.py
@ -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()
|
||||||
|
Reference in New Issue
Block a user