Handle ctrl-c while paging help gracefully

This commit is contained in:
Kovid Goyal 2018-12-03 13:53:13 +05:30
parent 222beedc2a
commit 8d9ba4a772
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -275,7 +275,10 @@ def print_help_for_seq(seq, usage, message, appname):
if print_help_for_seq.allow_pager and sys.stdout.isatty():
import subprocess
p = subprocess.Popen(['less', '-isRXF'], stdin=subprocess.PIPE)
try:
p.communicate(text.encode('utf-8'))
except KeyboardInterrupt:
raise SystemExit(1)
raise SystemExit(p.wait())
else:
print(text)