[sac-dev] [patch] Use a pager to show the help files
Kuang He
icrazy at gmail.com
Tue Sep 16 14:22:38 PDT 2008
Dear Brian,
On Tue, Sep 16, 2008 at 12:13 PM, Brian Savage <savage at uri.edu> wrote:
> There is similar code in src/dfm/xlh.c to do paging for the listhdr command,
> but it is
> coupled to the output of the command. Same for the news command. Would you
> suggest
> that we change the way these commands operate as well ? This could be done
> with a
> pipe to the pager. It might be more trouble than it is worth. This also
> modifies the current behavior of SAC.
I agree with you. For the time being, maybe we can just leave the
paging part of the listhdr command alone.
> Looks like less is available on Linux and OSX (the GNU version)
> I cannot find a version of less on Solaris, but Solaris does have the more
> command.
> I would propose doing a check like
> AC_CHECK_PROGS(SAC_PAGER, [ less more ])
> It would be nice to remove this code as the capability exists elsewhere
> outside of SAC.
>
> I still think having a fallback to the original SAC paging code is the
> safest thing to do.
There are some problems with checking for available pager programs
during the ./configure stage:
(1) For example, if the user does not have ``less'' during the
./configure stage, SAC will use ``more'' to do the paging. After SAC
is compiled and installed, if the users installs ``less'' but does not
set the environment variable $PAGER, SAC will still be using ``more''
all the time. Yes, it is the user's responsibility to set $PAGER
correctly, but who knows.
(2) If developer A compiles a binary SAC package on a system that has
``less'' installed and distributes it to user B who does not have
``less'' on her system, SAC will still try to use ``less'' as its
pager, which will result in a failure.
To solve this problem, I propose that we check for pager programs at
runtime, following the practice of ``man''. So when SAC starts, it'll
run through this decision process:
if the environment variable $PAGER is set to a non-empty value {
use it
} else {
SAC will look for executable files at these locations one by one
/usr/bin/less
/bin/less
/usr/bin/more
/bin/more
and will use the first one available.
If none of the above pages are available, SAC will fall back to its
original paging code.
}
Maybe we could put the above in the initialization part of SAC. How
does that sound?
Best regards,
--
Kuang He
Department of Physics
University of Connecticut
Storrs, CT 06269-3046
Tel: +1.860.486.4919
Web: http://www.phys.uconn.edu/~he/
More information about the sac-dev
mailing list