#! /bin/sh

# This script generates a list of the subdirectories of the current
# directory according to the following:
# 
# 	1. any subdirectory named RCS is excluded from the list;
# 	2. if there is a file called EXCLUDEDIRS in the current
# 	   directory, any directories whose names are listed
# 	   in that file are excluded.
#	3. if there is a file called FIRSTDIRS in the current
#	   directory, any directories whose names are listed
#	   in that directory are listed first in the list,
#	   in the order they appear in the file.
# 
# The resulting list is echoed on a single line to stdout.

firstdirs=""
if [ -r FIRSTDIRS ] ; then
  firstdirs="`cat FIRSTDIRS`" ;
fi
exceptions=`( echo ' 'RCS' ' ;
	      if [ -r EXCLUDEDIRS ] ; then
		cat EXCLUDEDIRS ;
	      fi ;
	      echo ' '$firstdirs' ')`
echo `if [ -r FIRSTDIRS ] ; then cat FIRSTDIRS ; fi ;
      for file in * ; do
        if [ -d $file ] ; then
          if echo \"$exceptions\" | fgrep -v " $file " 1>&- ; then
            echo $file ;
          fi
        fi ;
      done`
