Less hotkeys not working, printing keycodes instead performing action



When I try something like

php -i | less

Less is not responding to hotkeys, but prints them like pressing "q" results in statusline




Pressing ENTER like "executes" the keycode and less perfoems the action.

Piping trivial small stuff work however...

OS: Fedora 14


Posted 2011-03-14T23:16:36.307

Reputation: 43



php -i is doing something weird with stdin. Try this:

php -i </dev/null | less

Paused until further notice.

Posted 2011-03-14T23:16:36.307

Reputation: 86 075

Actually, it's less that does the "something weird". It changes to non-canonical mode input processing. Of course php may well be doing something as well, but this is simply a specific case of the more general don't have two programs simultaneously interacting with the terminal that employ different terminal input modes and expect things to work. – JdeBP – 2011-03-17T20:29:35.563

@JdeBP: less may very well be doing something weird, but this is from strace php -i without less: ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 – Paused until further notice. – 2011-03-17T21:00:00.050

Setting canonical mode input processing (icanon) is not "something weird". Canonical mode is the norm. Hence its name. – JdeBP – 2011-03-18T13:44:04.380

1@JdeBP: Well, I don't know what's hidden behind the ... and perhaps the clue lies elsewhere. But why is php -i opening stdin at all? It does this same odd behavior with more (which is not a symlink or alias on my system), but, interestingly, not pg or (inconsistently) most. PHP also does this with php -r 'for ($i = 1; $i <= 100; $i++) { print "$i\n"; }' | less. AWK, Perl, Python, etc., don't exhibit this weirdness. Conclusion: PHP is broken. – Paused until further notice. – 2011-03-18T14:42:21.620