There are two major problems that prevent an easy solution for the problem:
As indicated in the
mailxman page (SLES ships Nail’smailx), “Variables in the environment passed tomailxcannot be unset.”PAGER(as set from withinmailx) cannot have parameters, so something likeset PAGER="LESS=-F less"orset PAGER="sh -c LESS=-F less"do not work. To make things worse, there is no output if you try something likeset PAGER="less -F".
So the alternatives are:
mailxcan be configured to skip the pager if a message fits in a single screen by setting thecrtoption (that requires the number of lines of the terminal normally): addset crtto your
.mailrc. Without a value, the version ofmailxavailable in SLES uses the current screen height; POSIX doesn’t specify the behaviour whencrtis set without a value, so a POSIX-compliant approach is either to set it to 99999 (to always skip the pager) or a typical value for your work environment (to only use the pager when necessary).The pager can also be replaced with a non-paging display tool, e.g.
catwhen startingmailxfrom a Bourne-shell-like interpreter:PAGER=cat mailxIf your pager is
less, you can ask it to quit without prompting if it has less than a screen’s worth of text to display, using its-Foption (again usingshsyntax):LESS=F mailxIf you want to combine
-Fwith other options set in yourLESSvariable, useLESS="$LESS -F" mailxThis can be enabled in general by exporting
LESS=F(and any otherlessoption you want to enable by default) in your shell startup script.In versions of
lessolder than 530, you may need to combine-Fand-X(LESS=FX).