Skip to content
Myr

Handle ^C in less-pager properly.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

See #350

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parent 50c9f34 · Browse files · 2 files+17 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−1 removed

  • other:+17 added−1 removed

2 files+17 added−1 removed

modified:click/_termui_impl.py+16 added-1 removed
306 unmodified lines
307 c.stdin.write(text.encode(encoding, 'replace'))308 c.stdin.close()309 except IOError:310 pass311 c.wait()311312 # Less doesn't respect ^C, but catches it for its own UI purposes (aborting313 # search or other commands inside less).314 #315 # That means when the user hits ^C, the parent process (click) terminates,316 # but less is still alive, paging the output and messing up the terminal.317 #318 # If the user wants to make the pager exit on ^C, they should set319 # `LESS='-K'`. It's not our decision to make.320 while True:321 try:322 c.wait()323 except KeyboardInterrupt:324 pass325 else:326 break327328329def _tempfilepager(text, cmd, color):330 """Page through text by invoking a program on a temporary file."""331 import tempfile332 filename = tempfile.mktemp()
195 unmodified lines
modified:CHANGES+1 added
10 unmodified lines
11- Fix a bug where error messages would include a trailing `None` string.12- Fix a bug where Click would crash on docstrings with trailing newlines.13- Support streams with encoding set to `None` on Python 3 by barfing with14 a better error.15- Handle ^C in less-pager properly.1617Version 4.018-----------19
207 unmodified lines