1#!/bin/sh 2 3# This script extracts and compares the commands defined in the manual 4# to those defined in the source code. 5 6grep '^DEF_CMD' $1/../kernel/cmd.def \ 7 | sed -e 's/\\\\/\\/' \ 8 | sed -e 's:^[^(]*(\([^,]*\), "\([^"]*\)".*$:\1 \2:' \ 9 | sed -e "s/C('\(.\)')/C-\1/" -e "s/ *'\(.\)' /\1/" -e 's/ 0 /0/' \ 10 | sed -e "s/^ /' ' /" \ 11 | grep -v '0 D' \ 12 | sort | uniq >src.cmds 13 14# Join all @item lines with their following lines. 15 16cat $1/../doc/commands.texi \ 17 | sed -e 's/^@item \(.*\)$/@item \1 EOL/' \ 18 | sed -e '/^@item /{N;s/EOL.//;P;D;}' \ 19 >joined.txt 20 21# Single-letter commands. 22 23cat joined.txt \ 24 | grep -h "^@item [^'] " \ 25 | sed -e 's/^@item \(.\) (@code{\([^}]*\)}).*$/\1 \2/' \ 26 >doc.cmds1 27 28# Escaped single-letter commands. 29 30cat joined.txt \ 31 | grep -h "^@item @. " \ 32 | sed -e 's/^@item @\(.\) (@code{\([^}]*\)}).*$/\1 \2/' \ 33 >doc.cmds2 34 35# Quoted single-letter commands. 36 37cat joined.txt \ 38 | grep -h "^@item '.' " \ 39 | sed -e "s/^@item '\(.\)' (@code{\([^}]*\)}).*$/'\1' \2/" \ 40 >doc.cmds3 41 42# Control-character commands. 43 44cat joined.txt \ 45 | grep -h "^@item ^. " \ 46 | sed -e 's/^@item ^\(.\) (@code{\([^}]*\)}).*$/C-\1 \2/' \ 47 >doc.cmds4 48 49# Long-name-only commands. 50 51cat joined.txt \ 52 | grep -h "^@item [a-zA-Z][a-zA-Z-][a-zA-Z-]* " \ 53 | sed -e 's/@@/@/' \ 54 | sed -e 's/^@item \([a-zA-Z-]*\) .*$/0 \1/' \ 55 > doc.cmds5 56 57cat doc.cmds[1-5] | grep -v '0 D' | sort | uniq >doc.cmds 58 59echo "Differences between commands in reference manual and in source code:" 60echo "('<' - in documentation, '>' - in sources)" 61 62diff -w doc.cmds src.cmds 63 64exit 0 65