1 #!/bin/sh - 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # 23 # Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. 24 # 25 # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T 26 # All Rights Reserved 27 # 28 29 # University Copyright- Copyright (c) 1982, 1986, 1988 30 # The Regents of the University of California 31 # All Rights Reserved 32 # 33 # University Acknowledgment- Portions of this document are derived from 34 # software developed by the University of California, Berkeley, and its 35 # contributors 36 37 PATH=/usr/xpg4/bin:$PATH 38 39 tmpdir=/tmp/whatis.$$ 40 trap "rm -rf $tmpdir; exit 1" 1 2 13 15 41 42 mkdir -m 700 $tmpdir || { 43 echo "${0}: could not create temporary directory" 1&>2 44 exit 1 45 } 46 47 [ -d $1 ] || exit 1 48 49 cd $1 50 top=`pwd` 51 for i in man?* sman?* 52 do 53 if [ -d $i ] ; then 54 cd $i 55 if test "`echo *`" != "*" ; then 56 /usr/lib/getNAME * 57 fi 58 cd $top 59 fi 60 done >$tmpdir/whatisx 61 sed <$tmpdir/whatisx \ 62 -e 's/\\-/-/' \ 63 -e 's/\\\*-/-/' \ 64 -e 's/ VAX-11//' \ 65 -e 's/\\f[PRIB01234]//g' \ 66 -e 's/\\s[-+0-9]*//g' \ 67 -e 's/\\&//g' \ 68 -e '/ - /!d' \ 69 -e 's/.TH [^ ]* \([^ ]*\).* \(.*\) -/\2 (\1) -/' \ 70 -e 's/ / /g' | \ 71 awk '{ title = substr($0, 1, index($0, "- ") - 1) 72 synop = substr($0, index($0, "- ")) 73 count = split(title, n, " ") 74 for (i=1; i<count; i++) { 75 if ( (pos = index(n[i], ",")) || (pos = index(n[i], ":")) ) 76 n[i] = substr(n[i], 1, pos-1) 77 printf("%s\t%s %s\t%s\n", n[i], n[1], n[count], synop) 78 } 79 }' >$tmpdir/whatis 80 /usr/bin/expand -16,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100 \ 81 $tmpdir/whatis | LC_CTYPE=C LC_COLLATE=C sort -u | \ 82 /usr/bin/unexpand -a > windex 83 chmod 644 windex >/dev/null 2>&1 84 rm -rf $tmpdir 85 exit 0