display usage info if required args not passed

This commit is contained in:
Bhuvanesh Kumar
2014-01-29 00:18:38 +05:30
parent 45a90310e3
commit 18258ad2a9
+8
View File
@@ -24,6 +24,9 @@ trap 'fn_terminate_script' SIGINT
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Small utility functions for reducing code duplication # Small utility functions for reducing code duplication
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
fn_display_usage() {
fn_log_info "Usage : $(basename $0) <source> <destination> [exclude-pattern file]"
}
fn_parse_date() { fn_parse_date() {
# Converts YYYY-MM-DD-HHMMSS to YYYY-MM-DD HH:MM:SS and then to Unix Epoch. # Converts YYYY-MM-DD-HHMMSS to YYYY-MM-DD HH:MM:SS and then to Unix Epoch.
@@ -53,6 +56,11 @@ fn_expire_backup() {
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Source and destination information # Source and destination information
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
#display usage information if required arguments are not passed
if [[ "${#@}" -lt 2 ]]; then
fn_display_usage
exit 1
fi
SRC_FOLDER="${1%/}" SRC_FOLDER="${1%/}"
DEST_FOLDER="${2%/}" DEST_FOLDER="${2%/}"