# $Copyright:	$
# Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
# Sequent Computer Systems, Inc.   All rights reserved.
#  
# This software is furnished under a license and may be used
# only in accordance with the terms of that license and with the
# inclusion of the above copyright notice.   This software may not
# be provided or otherwise made available to, or used by, any
# other person.  No title to or ownership of the software is
# hereby transferred.
#ident	"$Header: subcommands 1.2 89/10/10 $@(#)sadmin:tools/subcommands	2.2"
#	produce list of commands available under sysadm command

#!	chmod +x ${file}

if [ $# -ne 1 ]
then
	echo >&2 "Usage:  $0 menu-directory"
	exit 1
fi

cd $1
for f in `find * -type f  -print  |  sort`
{
	if [ ${f} = DESC ]
	then
		continue
	fi
	F=`case ${f} in
	*DESC )
		dirname /${f}
		;;
	* )
		echo /${f}
	esac  |  sed '	s;[^/]*/;\\\\\\\\(bu ;g'`

	#	sed and tr commands use the BELL character (^g)
	sed -n "
		/^#menu#[ 	]*/ {
			s;^#menu#[ 	]*;.IP \"${F}\";"'
			p
		}
		/^#help#/{
			s/^#help#[ 	]*//
			s/   */ /g
			s/\. /./g
			/^$/s///
			p
		}
		' ${f}  |
	   tr '	' ' \012'
}
