Has anyone else noticed how the GNU ‘less’ command has been getting really smart, perhaps too smart for its own good? When you aim the command at a non-text file, it does its best to interpret the type and display it in a readable manner.
- source code: ‘less’ originally displayed the text unadorned. Now it calls some program to colorize the syntax, which is nice, except when it’s an inordinately large source file on a rather slow computer and the external colorizer program takes forever. Ctrl-C asks the colorizer to quit and allows ‘less’ to process with the regular text.
- HTML: ‘less’ used to show you the raw HTML text. The programs now formats the HTML the best it can.
- directories: ‘less’ used to advise you that the requested target was actually a directory. Now it offers a directory listing.
- ELF: ‘less’ used to inform you that the file appeared binary in nature and asked if you still wanted ‘less’ to try to display it anyway. Now it parses header information, apparently using ‘readelf -a’.
- binary: Like ELF, ‘less’ used to notify you that the data appears binary. Now it shows you a rudimentary hex view. This confused me the most. “Wait, does this file actually contain a text listing of a hex dump?” I then have to open a proper hex editor to verify that this is not the case.
Hey, that’s just because you use it actually the right way, instead of e.g. the “useless use of cat” way: “cat file | less”.
Now for those who want the benefits with this useless can can of course choose “less
Hm… I wonder what happened to the rest of my post….
It looks like the next character might have been a less-than symbol, which needs to be represented as < in an HTML forum. Perhaps I should see if there is a plugin that works around this problem somehow since this is a code-heavy blog.
GNU less has the option to pre-process the input by setting the LESSOPEN environment variable. It’s had this option for ages (at least since 1994 it seems).
Are you by any chance using a distribution that supplies its own preprocess script and sets LESSOPEN in /etc/profile or so?
Perhaps. I just know that one day I was using Gentoo and I noticed that less was doing different, sometimes unintuitive things, than it did before. Maybe one of the emerge updates decided to configure a new default behavior. Free software has a nasty habit of doing that (I’m looking in KDE’s direction here).