]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/tools/sysdoc/sysctl.sh
zfs: merge openzfs/zfs@8f2f6cd2a
[FreeBSD/FreeBSD.git] / tools / tools / sysdoc / sysctl.sh
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
14 name="$1"
15 if [ X"${name}" = X"" ]; then
16         echo "usage: $(basename $0) sysctl-name" >&2
17         exit 1
18 fi
19
20
21 # Look up $name in tunables.mdoc
22
23 < tunables.mdoc \
24 sed -ne "/^${name}[[:space:]]*$/,/^---[[:space:]]*$/p" |        \
25 sed -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 }