#!/bin/sh 
# samedirsunder -- takes 2 directories as arguments,
#         outputs on stdout a list of all subdirectory names that are under both
#         (with the same name).
#
# AUTHOR:	Gary T. Leavens

[ -n "$echo" ] && set -x

USAGE="$0 old-dir new-dir"

# needs 2 arguments
if test $# -ne 2
then
	echo "$USAGE" >&2
	exit 1
fi

OLDDIR=$1
NEWDIR=$2

for d in "$OLDDIR" "$NEWDIR"
do
    if test \! -d "$d"
    then
	echo "$d does not exist or is not readable!" >&2
	exit 2
    fi
done

for d in `ls -1 $OLDDIR`
do
	if test -d "$OLDDIR/$d" -a -d "$NEWDIR/$d"
	then
	    echo $d
	fi
done
