summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1997-11-13 04:40:14 +0000
committermillert <millert@openbsd.org>1997-11-13 04:40:14 +0000
commit9a70283e83484d94aff8ebe9059b4a5f209738ab (patch)
treeef92cdf1247234fe7ad7b34c90300ccfc3ab33c5
parentNuke trailing space. (diff)
downloadwireguard-openbsd-9a70283e83484d94aff8ebe9059b4a5f209738ab.tar.xz
wireguard-openbsd-9a70283e83484d94aff8ebe9059b4a5f209738ab.zip
From NetBSD:
makewhatis.sh rewrite by mrg@netbsd.org that uses getNAME(8). Much faster for unformatted man pages now that there is no need to format them on the fly. Removes duplicate inode entries, so files with multiple hard links are only parsed once. OpenBSD changes: set $PATH to a reasonable value avoid /tmp races via mktemp(1) obey $TMPDIR
-rw-r--r--libexec/makewhatis/makewhatis.817
-rw-r--r--libexec/makewhatis/makewhatis.sh54
2 files changed, 37 insertions, 34 deletions
diff --git a/libexec/makewhatis/makewhatis.8 b/libexec/makewhatis/makewhatis.8
index 2affe6e76f6..5ee26a99705 100644
--- a/libexec/makewhatis/makewhatis.8
+++ b/libexec/makewhatis/makewhatis.8
@@ -1,5 +1,5 @@
-.\" $OpenBSD: makewhatis.8,v 1.1 1997/11/05 19:20:47 deraadt Exp $
-.\" $NetBSD: makewhatis.8,v 1.2 1997/10/20 02:41:18 enami Exp $
+.\" $OpenBSD: makewhatis.8,v 1.2 1997/11/13 04:40:14 millert Exp $
+.\" $NetBSD: makewhatis.8,v 1.2.2.1 1997/11/10 19:57:45 thorpej Exp $
.\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -53,7 +53,8 @@ for use in
.Xr apropos 1
or with
.Xr man 1 's
--k option.
+.Fl k
+option.
If
.Ar manpath
is unspecified,
@@ -64,12 +65,12 @@ Man pages compressed with
and
.Xr gzip 1
are uncompressed before processing, unformatted man pages
-will be formatted on the fly.
+will be processed by
+.Xr getNAME 8 .
.Sh BUGS
.Nm
should find its search paths using /etc/man.conf
.Sh SEE ALSO
.Xr man 1 ,
-.Xr man.conf 5
-.Sh AUTHOR
-J.T. Conklin (jtc@netbsd.org)
+.Xr man.conf 5 ,
+.Xr getNAME 8
diff --git a/libexec/makewhatis/makewhatis.sh b/libexec/makewhatis/makewhatis.sh
index c18570936c1..814f6117495 100644
--- a/libexec/makewhatis/makewhatis.sh
+++ b/libexec/makewhatis/makewhatis.sh
@@ -1,47 +1,49 @@
#! /bin/sh
#
-# Written by J.T. Conklin <jtc@netbsd.org>.
+# written by matthew green <mrg@eterna.com.au>, based on the
+# original by J.T. Conklin <jtc@netbsd.org> and Thorsten
+# Frueauf <frueauf@ira.uka.de>.
+#
# Public domain.
#
+# $OpenBSD: makewhatis.sh,v 1.5 1997/11/13 04:40:15 millert Exp $
+#
-TDIR=/tmp/whatis$$
-FILE=$TDIR/whatis
+PATH=/usr/bin:/bin; export PATH
-um=`umask`
-umask 022
-if ! mkdir $TDIR ; then
- printf "tmp directory %s already exists, looks like:\n" $TDIR
- ls -alF $TDIR
+# Create temp files safely
+LIST=`mktemp ${TMPDIR=/tmp}/makewhatislist.XXXXXXXXXX` || exit 1
+WHATIS=`mktemp ${TMPDIR=/tmp}/whatis.XXXXXXXXXX` || {
+ rm -f $LIST
exit 1
-fi
-umask $um
-
-trap "rm -rf $TDIR; exit 1" 1 2 15
+}
+trap "rm -f $LIST $WHATIS; exit 1" 1 2 15
MANDIR=${1-/usr/share/man}
if test ! -d "$MANDIR"; then
echo "makewhatis: $MANDIR: not a directory"
- rm -rf $TDIR
+ rm -f $LIST $WHATIS
exit 1
fi
-find $MANDIR -type f -name '*.0' -print | while read file
-do
- sed -n -f /usr/share/man/makewhatis.sed $file;
-done > $FILE
+find $MANDIR \( -type f -o -type l \) -name '*.[0-9]*' -ls | \
+ sort -n | awk '{if (u[$1]) next; u[$1]++ ; print $11}' > $LIST
+
+egrep '\.[1-9]$' $LIST | xargs /usr/libexec/getNAME | \
+ sed -e 's/ [a-zA-Z0-9]* \\-/ -/' >> $WHATIS
-find $MANDIR -type f -name '*.0.Z' -print | while read file
+egrep '\.0$' $LIST | while read file
do
- zcat $file | sed -n -f /usr/share/man/makewhatis.sed;
-done >> $FILE
+ sed -n -f /usr/share/man/makewhatis.sed $file;
+done > $WHATIS
-find $MANDIR -type f -name '*.0.gz' -print | while read file
+egrep '\.[0].(gz|Z)$' $LIST | while read file
do
- gzip -dc $file | sed -n -f /usr/share/man/makewhatis.sed;
-done >> $FILE
+ gzip -fdc $file | sed -n -f /usr/share/man/makewhatis.sed;
+done >> $WHATIS
-sort -u -o $FILE $FILE
+sort -u -o $WHATIS $WHATIS
-install -o bin -g bin -m 444 $FILE "$MANDIR/whatis.db"
-rm -rf $TDIR
+install -o root -g bin -m 444 $WHATIS "$MANDIR/whatis.db"
+rm -f $LIST $WHATIS
exit 0