[sac-dev] [patch] Use a pager to show the help files

Kuang He icrazy at gmail.com
Sun Sep 14 00:41:41 PDT 2008

Hi all,

Attached is a patch (against v101.2) to make SAC use a pager specified
by environment variable $PAGER, instead of the current home-grown tool
similar to ``more'', to show the help files. The good thing is that in
this way, people get to use their favorite pager when viewing the help
files. I personally use ``less'', and its biggest advantage over
``more'' is that it can support scrolling backwards using hotkeys like
Up Arrow, PageDown, Ctrl+U, k, etc. Plus, I get to scroll either way
by a few lines or by half a page, i.e. not necessarily by a whole

Known caveat:

- When the user have an unreasonable setting of $PAGER, the error
message of not being able to load the pager might be a bit mysterious
to the users.

$ export PAGER=xxx
$ sac
SAC> h fg
sh: xxx: not found

- I did not check the return value of malloc() in my code, since I was
hoping someone could come up with a uniform way of reporting malloc()
errors so that we could all stick to it. One possible way is to have a
warpper function to malloc(), and use that instead of malloc() all the
time. And yes, I am aware that there are SO MANY malloc()'s in the
code, whose return values have not been checked!

void *
xmalloc(size_t size)
    void *p;

    if ((p = malloc(size)) == NULL)
        fprintf(stderr, "Malloc failed: %s", strerror(errno));
    return (p);

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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pager-help-file.diff
Type: application/octet-stream
Size: 2622 bytes
Desc: not available
URL: <http://www.iris.washington.edu/pipermail/sac-dev/attachments/20080914/0fe7518c/attachment.obj>

More information about the sac-dev mailing list