Fix an annoying apropos glitch
One of the most useful
commands in the terminal is
apropos(1).
It prints out summaries of all
man(1)
pages related to a given keyword. However, an annoying interaction between
certain improperly formatted
man
pages and the
makewhatis(8)
command may cause entire pages to be written out by
apropos,
which can make it very difficult to read.
apropos
serial produces an
example of the glitch, which arose years ago in FreeBSD and which OS/X has
inherited. However, since the
apropos
command is a shell script, there is a very simple workaround.
You can either
make the change in place, in
/usr/bin/apropos,
or you can place a copy of the original somewhere earlier in your path and edit
the copy. The modification is placed at the very end of the script, and involves
inserting the command cut -c1-80
| into the pipeline,
immediately before the
$PAGER
invocation. Here is the resulting
line:
( printf -- "$line2";
echo "$line"; cat ) | cut -c1-80 |
$PAGER
What the modification
does is to truncate all characters to the right of column 80. The change will
also truncate summary lines that are valid but long -- if you think more data
should be written out, change the
80
to whatever you prefer.
[robg
adds: I tested this by
first backing up the original
apropos,
and then editing it with sudo vi
apropos. I changed the
last line and then saved the file (I had to use
w!
in
vi
to override the read-only flag). It worked as described;
apropos
serial now produces
reasonable output...]
Posted: Thu - January 20, 2005 at 10:46 PM