trap 'rm -f /tmp/?$$; exit 1' 1 2 3 15
trap 'rm -f /tmp/?$$; exit 0' 0
NL='
'

# scan for options
A= F=
for i do
	case $i in
	-[nwf]*)	F="$F $i"
		;;
	-*)	prompt "$i: unknown flag$NL"
		;;
	*)	A="$A $i"
		;;
	esac
done

${LIB?}/bin/wir -x $A >/tmp/w$$
 grep '^\.[cvw]' </tmp/w$$ |
  sort -u +2 -3 +3nr +0 |
  $LIB/bin/wref-a

echo "${NL}${NL}SIGNAL          FILE            REFERENCES"
grep '^.w' </tmp/w$$ |
 sort -u +0 -3 +0 |
  sed -e 's/ /:/;s/ /:/;s/ \(.*\)/(\1)/;s/^.w//' |
   $LIB/bin/wref-b -f12 $F
