summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bruce Park <r@robru.ca>2013-11-26 12:55:17 -0800
committerRobert Bruce Park <r@robru.ca>2013-11-26 12:55:17 -0800
commit0db8b3a913ff2cd890584284f1408ba095fb8e43 (patch)
tree9c178d71ee1683b1ece8d31e195aa248522f9b8f
parentc3f15c7834c42c5fc7575a8e611848441ee031e5 (diff)
Define trivial functions on one line only.
-rw-r--r--rsync_tmbackup.sh29
1 files changed, 8 insertions, 21 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh
index 5d3439e..4a42b1f 100644
--- a/rsync_tmbackup.sh
+++ b/rsync_tmbackup.sh
@@ -4,24 +4,16 @@
# Log functions
# -----------------------------------------------------------------------------
-fn_log_info() {
- echo "rsync_tmbackup: $1"
-}
-
-fn_log_warn() {
- echo "rsync_tmbackup: [WARNING] $1"
-}
-
-fn_log_error() {
- echo "rsync_tmbackup: [ERROR] $1"
-}
+fn_log_info() { echo "rsync_tmbackup: $1"; }
+fn_log_warn() { echo "rsync_tmbackup: [WARNING] $1"; }
+fn_log_error() { echo "rsync_tmbackup: [ERROR] $1"; }
# -----------------------------------------------------------------------------
# Make sure everything really stops when CTRL+C is pressed
# -----------------------------------------------------------------------------
fn_terminate_script() {
- echo "rsync_tmbackup: SIGINT caught."
+ fn_log_info "SIGINT caught."
exit 1
}
@@ -46,7 +38,7 @@ fn_find_backups() {
fn_expire_backup() {
# Double-check that we're on a backup destination to be completely
# sure we're deleting the right folder
- if [ -z "$(fn_is_backup_destination "$(dirname -- "$1")")" ]; then
+ if [ -z "$(fn_find_backup_marker "$(dirname -- "$1")")" ]; then
fn_log_error "$1 is not on a backup destination - aborting."
exit 1
fi
@@ -76,15 +68,10 @@ done
# TODO: check that the destination supports hard links
-fn_backup_marker_path() {
- echo "$1/backup.marker"
-}
-
-fn_is_backup_destination() {
- find "$(fn_backup_marker_path "$1")" 2>/dev/null
-}
+fn_backup_marker_path() { echo "$1/backup.marker"; }
+fn_find_backup_marker() { find "$(fn_backup_marker_path "$1")" 2>/dev/null; }
-if [ -z "$(fn_is_backup_destination $DEST_FOLDER)" ]; then
+if [ -z "$(fn_find_backup_marker "$DEST_FOLDER")" ]; then
fn_log_info "Safety check failed - the destination does not appear to be a backup folder or drive (marker file not found)."
fn_log_info "If it is indeed a backup folder, you may add the marker file by running the following command:"
fn_log_info ""