cd $HOME
More is Less -E (More or Less)
I had an interesting issue today: how to deal with the environment variable PAGER?
Here’s the big picture: not all distributions use the same default pager. You have on one side the more fans (Debian) and on the other side the less ones (Suse). I’m not taking into account the geeks who use something else (probably well tweaked).
Imagine now you want to display to the user your EULA in an installation script. How should you display it? Using more by default? Or PAGER? The second solution seems intuitive to me. After all, if I use a special, personal pager, I would be totally frustrated to have to deal with more when reading the EULA.
However, think about the beginner Suse user, who doesn’t know much about less. Reaching EOF, less will stop scrolling, if neither -e nor -E are specified. You need to type q to exit. The beginner would have no idea what to do to exit less.
The solution I came up with is to either use more if no pager is specified, and use PAGER otherwise. In the latter case, if is it less, -E is appended at the command line, with the regular flags the user might have specified in PAGER.
The solution works well. If no pager is specified or less is, the behavior will be to exit the pager when EOF is reached and the script can continue (“Do you accept…”). If a special, tweaked, pager is specified, it is very likely that the user specified it, so he know how to use it. And he won’t be frustrated when reading the text.





Comments