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