# tree.sh - display directory trees
#
# J.L. Wilson                                          9/13/89
#
# Displays the directory structure of the given root node in a
# format similar to DOS VTREE.
#
USAGE="Usage:  $0 [directory]"
case $# in
   0)  dir=`pwd` ;;
   1)  if [ ! -d $1 ]; then
           echo "$1:  not a directory" >$2
           echo $USAGE >$2
           exit 1
       fi
       dir=$1 ;;
   *)  echo $USAGE
       exit 1 ;;
esac
echo " "
cd $dir
cdir=`pwd`
if [ $cdir = "/" ]
then
   find . -type d -print |
   sort |
   awk -F/ 'NR == 1 { print "/" }
            NR > 1 { for (count = 1; count < NF-1; count++)
                       printf "          "
                       print "   |----> "$NF }'
else
   find . -type d -print |
   sort |
   awk -F/ 'NR == 1 { print "'`basename $cdir`'" }
            NR > 1 { for (count = 1; count < NF-1; count++)
                       printf "          "
                       print "   |----> "$NF }'
fi
echo " "



