blob: d96330f01a35f32d2a1a46f0378cde33325a3756 [file] [log] [blame]
david_williams5dc46da2008-01-13 06:39:38 +00001#!/bin/bash
david_williamsac075f82008-01-13 04:05:08 +00002
david_williams5dc46da2008-01-13 06:39:38 +00003# echo "arg: $1";
4
5if [ -z $1 ]
6 then
david_williamsac075f82008-01-13 04:05:08 +00007 echo " This script requires an argument. " ;
8 exit 1;
9 fi
10
david_williams5dc46da2008-01-13 06:39:38 +000011foundDirectory=$1
12# should already be in foundDirectory, if execDir used
david_williamsac075f82008-01-13 04:05:08 +000013cd $foundDirectory
david_williams312a06a2008-01-16 01:59:25 +000014# move up one so we can examine syblings
david_williamsac075f82008-01-13 04:05:08 +000015cd ..
david_williams5dc46da2008-01-13 06:39:38 +000016currentDirectory=`pwd`
17echo $currentDirectory
18ndirs=`ls -lA | wc -l`
david_williams312a06a2008-01-16 01:59:25 +000019ndirs=$(($ndirs - 1)); # don't count the "totals" line
david_williams5dc46da2008-01-13 06:39:38 +000020# echo "NDirs: $ndirs"
david_williamsac075f82008-01-13 04:05:08 +000021
david_williams5dc46da2008-01-13 06:39:38 +000022# if only one left, do not remove it, no matter how old
david_williams8a121722008-07-16 04:42:54 +000023if [ $ndirs -eq 1 ]
david_williams5dc46da2008-01-13 06:39:38 +000024then
25 exit 0;
26fi
david_williams8a121722008-07-16 04:42:54 +000027# This is unexpected, since otherwise this method should not have been called.
28# So, this check is just a safety check.
29if [ $ndirs -lt 1 ]
30then
31 exit 101;
32fi
33
david_williams5dc46da2008-01-13 06:39:38 +000034# ok, it is old, and not the only one left
david_williams8a121722008-07-16 04:42:54 +000035# adding a few "should never happen" errror checks
36if [ -d $foundDirectory ]
37then
38 rm -fr $foundDirectory
39else
40 echo "ERROR: the foundDirectory, $foundDirectory, is not a directory"
41fi