#!/bin/csh -f
# a script to identify the objects described in each descript.html
# file in subdirectories below $STARTWHERE/../objects
#
echo "This script is a simple-minded search for files named 'descript.html'."
echo "It assumes the following:"
echo "  1.  You are the user who owns the JGOFS system and its files."
echo "  2.  You are running this script from the htmlbin directory."
echo ""
echo "** Both assumptions must be correct before proceeding **"
echo ""
echo -n "Based on the above requirements, can you continue?(y/n)"
set ans=$<
if ($ans != 'y' && $ans != 'Y') then
  exit
endif

set STARTWHERE=`pwd`

set BEGINDIR=$STARTWHERE/../objects/
cd $BEGINDIR

foreach i ( `find . -type d -print | grep "./[a-zA-Z0-9]*"`)
  echo $i
  cd $i
  if (-e descript.html) then
    nawk '\
BEGIN {ok=0}\
/^[A-Za-z0-9].+$/ {ivar=$0;ok=1-ok}\
ivar == $0 && ok == 1 {print $0} ' descript.html >object.list

  endif
  cd $BEGINDIR
end
cd $STARTWHERE 
