Skip to content

Commit

Permalink
support bare config for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronhurt committed Aug 30, 2024
1 parent 64a43fe commit 96cf884
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions zfs-replicate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,11 @@ loadConfig() {
TAG="$(subTags "$TAG")"
LOG_FILE="$(subTags "$LOG_FILE")"
## process command-line options
opt=${1:-""} optArg=${2:-""}
while [ $# -gt 0 ]; do
case "$1" in
case "$opt" in
-c | --config)
configFile=$2
configFile="$optArg"
shift
;;
-s | --status)
Expand All @@ -465,7 +466,14 @@ loadConfig() {
-h | --help)
showHelp
;;
*) # bad long option
*)
## check for config file for backwards compatibility
if [ -z "$configFile" ] && [ -f "$opt" ]; then
configFile="$opt"
shift
continue
fi
## nothing left, error out
writeLog "ERROR: illegal option ${1}" && exit 1
;;
esac
Expand Down

0 comments on commit 96cf884

Please sign in to comment.