summaryrefslogtreecommitdiff
path: root/includes/generic-includes.sh
diff options
context:
space:
mode:
Diffstat (limited to 'includes/generic-includes.sh')
-rw-r--r--includes/generic-includes.sh46
1 files changed, 40 insertions, 6 deletions
diff --git a/includes/generic-includes.sh b/includes/generic-includes.sh
index ac62dd2..b58177b 100644
--- a/includes/generic-includes.sh
+++ b/includes/generic-includes.sh
@@ -141,22 +141,56 @@ function parseargs
function copylower
{
# usage: copylower source destination
+ mkdir -p "$2"
+
if [ -d "$1" ]; then
for filename in $(find "$1" -type f); do
- lowerpath="$(echo $filename|gawk -F "$1" '{print $2}'|tr A-Z a-z)"
- cp -f "$filename" "$2/$lowerpath" || die
+ lowerpath="$(echo $filename|gawk -F '$1' '{print $2}'|tr A-Z a-z)"
+ cp -f "$filename" "${2}/${lowerpath}" || die
done
elif [ -f "$1" ]; then
lowername="$(basename $1|tr A-Z a-z)"
- cp -f "$1" "$2"/$lowername
+ cp -f "$1" "${2}/${lowername}"
fi
}
+function setlower
+{
+ # usage: setlower target
+ if [ "$1" ]
+ then
+ cd "$1"
+ for each_file in `find ./ -iname "*"`
+ do
+ lower="`echo "$each_file" | tr "[:upper:]" "[:lower:]"`"
+
+ if [ "$each_file" != "$lower" ]
+ then
+ mv "$each_file" "$lower"
+ fi
+ done
+ fi
+}
+
function move_and_remove
{
# usage: move_and_remove source destination
# copies the files in the source directory to the destination.
- mkdir -p "$2" || die
- cp -R "$1/"* "$2" || die
- rm -r "$1"
+ if [ "$1" != "$2" ]
+ then
+ mkdir -p "$2" || die
+ cp -R "$1/"* "$2" || die
+ rm -r "$1"
+ fi
+}
+
+function teardown
+{
+ # usage: teardown target
+ if [ "$1" ]
+ then
+ cleanuptmp
+ setperms "$1"
+ setlower "$1"
+ fi
}