blob: d96330f01a35f32d2a1a46f0378cde33325a3756 [file] [log] [blame]
#!/bin/bash
# echo "arg: $1";
if [ -z $1 ]
then
echo " This script requires an argument. " ;
exit 1;
fi
foundDirectory=$1
# should already be in foundDirectory, if execDir used
cd $foundDirectory
# move up one so we can examine syblings
cd ..
currentDirectory=`pwd`
echo $currentDirectory
ndirs=`ls -lA | wc -l`
ndirs=$(($ndirs - 1)); # don't count the "totals" line
# echo "NDirs: $ndirs"
# if only one left, do not remove it, no matter how old
if [ $ndirs -eq 1 ]
then
exit 0;
fi
# This is unexpected, since otherwise this method should not have been called.
# So, this check is just a safety check.
if [ $ndirs -lt 1 ]
then
exit 101;
fi
# ok, it is old, and not the only one left
# adding a few "should never happen" errror checks
if [ -d $foundDirectory ]
then
rm -fr $foundDirectory
else
echo "ERROR: the foundDirectory, $foundDirectory, is not a directory"
fi