Skip to content

Commit

Permalink
Implement SeeSpotRuns approach to cleaning up empty dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
sahib committed Jun 15, 2017
1 parent 1f1c05e commit 0365cc5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/formats/sh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ DO_CLONE_READONLY=
# Set to true on -q
DO_SHOW_PROGRESS=true

# Set to true on -c
DO_DELETE_EMPTY_DIRS=

##################################
# GENERAL LINT HANDLER FUNCTIONS #
##################################
Expand Down Expand Up @@ -229,6 +232,14 @@ remove_cmd() {
if original_check "$1" "$2"; then
if [ -z "$DO_DRY_RUN" ]; then
rm -rf "$1"

if [ ! -z "$DO_DELETE_EMPTY_DIRS" ]; then
DIR=$(dirname "$1")
while [ ! "$(ls -A $DIR)" ]; do
rmdir "$DIR"
DIR=$(dirname "$DIR")
done
fi
fi
fi
}
Expand Down Expand Up @@ -282,7 +293,7 @@ EOF
DO_REMOVE=
DO_ASK=

while getopts "dhxnrpq" OPTION
while getopts "dhxnrpqc" OPTION
do
case $OPTION in
h)
Expand All @@ -306,6 +317,9 @@ do
p)
DO_PARANOID_CHECK=true
;;
c)
DO_DELETE_EMPTY_DIRS=true
;;
q)
DO_SHOW_PROGRESS=
;;
Expand Down

0 comments on commit 0365cc5

Please sign in to comment.