Make main() in pt-stalk.

This commit is contained in:
Daniel Nichter
2011-11-01 11:39:04 -06:00
parent dfad96537e
commit 255ea01fd8

View File

@@ -99,6 +99,9 @@ log() {
echo "${1}" >&2
}
# The main code that runs by default. Arguments are the command-line options.
main() {
# Make the collection location
mkdir -p "${DEST}" || die "Can't make the destination directory"
test -d "${DEST}" || die "${DEST} isn't a directory"
@@ -109,8 +112,8 @@ if [ "$(id -u)" != "0" ]; then
echo 'Not running with root privileges!';
fi
# We increment this variable every time that the check is true, and set it to 0
# if it's false.
# We increment this variable every time that the check is true,
# and set it to 0 if it's false.
cycles_true=0;
while true; do
@@ -158,6 +161,13 @@ while true; do
-depth -mtime +${PURGE} -exec rm -f '{}' \;
done
}
# Execute the program if it was not included from another file.
# This makes it possible to include without executing, and thus test.
if [ "$(basename "$0")" = "pt-stalk" ] || [ "$(basename "$0")" = "bash" -a "$_" = "$0" ]; then
main "$@"
fi
# ############################################################################
# Documentation