sysctl.sh revision 225736
1#!/bin/sh
2#
3# $FreeBSD: stable/9/tools/tools/sysdoc/sysctl.sh 142871 2005-03-01 05:48:37Z trhodes $
4#
5# For each sysctl, repeat:
6#	if it has a short description
7#		sysctl.sh name "descr"
8#	else
9#		write its name to tunables.TODO with 'name missing description'
10#		Note: This functionality is to point out which sysctls/tunables
11#		have no description in the source.  This may be helpful for those
12#		wishing to document the sysctls.
13#
14
15name="$1"
16if [ X"${name}" = X"" ]; then
17	echo "usage: $(basename $0) sysctl-name" >&2
18	exit 1
19fi
20
21
22# Look up $name in tunables.mdoc
23
24< tunables.mdoc \
25sed -ne "/^${name}[[:space:]]*$/,/^---[[:space:]]*$/p" |	\
26sed -e '/^---[[:space:]]*$/d' |					\
27
28{								\
29	read tmpname _junk;					\
30	if [ X"${tmpname}" = X"" ]; then			\
31		exit 0;						\
32	fi ;							\
33	read type value _junk;					\
34	unset _junk;						\
35	if [ X"${type}" = X"" ]; then				\
36		echo "" >&2 ;					\
37		echo "ERROR: Missing type for ${name}" >&2 ;	\
38	fi ;							\
39	if [ X"${value}" = X"" ]; then				\
40		echo "" >&2 ;					\
41		echo "ERROR: Missing default for ${name}" >&2 ;	\
42	fi ;							\
43
44	echo ".It Va ${tmpname}" ;				\
45    	if [ X"${type}" != X"" ]; then				\
46		echo ".Pq Vt ${type}" ;				\
47	fi ;							\
48	grep -v '^[[:space:]]*$' |				\
49	sed -e "s/@default@/${value}/g" |			\
50	sed -e "s/@type@/${type}/g" ;				\
51}
52