less
less copied to clipboard
Ctrl-C has no effect with + or -c (--clear-screen) option and process substitution
An example with zsh (with process substitution instead of a pipe, the command producing data runs in background and is not interrupted by the Ctrl-C):
less -fc <(echo foo; sleep 3; echo bar)
If I hit Ctrl-C during the sleep 3
, it has no effect. This is due to the fact that to complete the screen display in the presence of a +
or -c
option, less
still tries to take input into account.
I've reported the bug in the Debian BTS, with details on where the code yields the issue: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=931216
This is an older less
version (487), but the bug still occurs in version 551. I've attached a patch there, which works for me, but I'm not sure that's the right way.
I wonder if the -c option should be removed. Originally it was intended to improve the visual appearance of the screen while repainting. But in almost all modern environments repainting is nearly instantaneous so there is no perceptible difference between using -c or not.
I use the -c option to get the contents at the top (when the number of lines is less than the one of the terminal). But perhaps there's another solution for that.
I believe this is fixed in less-617.
I've just tested the current version from git on my example, and I confirm that this is fixed (both Ctrl-C and Ctrl-X now work). But since neither Debian nor Termux (Android) have upgraded yet, I couldn't test in my day-to-day work. Thanks.