plan9fox/rc/bin/sig
Ori Bernstein 5bc9b0c3ca improve usage messages (thanks henesy)
Fix inconsistencies between programs and their usage
messages,  correct instances where information seems
to be missing or lost. This  includes missing arguments,
making usage consistent with manuals, and so on.
2020-03-10 10:09:34 -07:00

29 lines
532 B
Bash
Executable file

#!/bin/rc
# Usage: sig key ...
# prints out function signatures by grepping the manual
*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_ \012'} # fold case, delete funny chars
if(~ $#* 0){
echo usage: sig function ... >/fd/2
exit usage
}
for (i) {
files=`{grep -il '[ ]\*?'$i'\(' /sys/man/2/*}
for(j in $files) {
{echo .nr LL 20i; sed -n '/^.SH SYNOPSIS/,/^.SH.*DESCR/p' $j } |
nroff -man |
sed '
:a
/,$/ {
N
s/\n//
}
ta
s/[ ]+/ /g' |
grep -i -e '[ *]'$i'\(' | sed 's/^[ +]/ /'
}
}
exit 0