less icon indicating copy to clipboard operation
less copied to clipboard

Ctrl-C has no effect with + or -c (--clear-screen) option and process substitution

Open vinc17fr opened this issue 5 years ago • 2 comments

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.

vinc17fr avatar Jun 29 '19 01:06 vinc17fr

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.

gwsw avatar Aug 01 '19 19:08 gwsw

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.

vinc17fr avatar Aug 01 '19 22:08 vinc17fr

I believe this is fixed in less-617.

gwsw avatar Dec 10 '22 19:12 gwsw

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.

vinc17fr avatar Dec 30 '22 00:12 vinc17fr