rsync input handling improv

This commit is contained in:
2026-03-27 18:05:57 +00:00
parent 1b9f584fb9
commit 5ece52b5e5
+23 -8
View File
@@ -25,15 +25,30 @@ source "$SCRIPT_DIR/../common.sh"
parse_args "$@"
# ----------------------------- INPUT -----------------------------
if [[ -z "$DIRECTORY" ]]; then
if [[ "${1:-}" != "" && "${1:-}" != --* && "${1:-}" != *=* ]]; then
DIRECTORY="$1"
shift
fi
fi
# ----------------------------
# INPUT HANDLING (FIXED)
# ----------------------------
[[ -z "$DIRECTORY" ]] && error "Missing directory" && exit 1
DIRECTORY=""
for ARG in "$@"; do
case "$ARG" in
--*|*=*)
# skip flags and key=value
;;
*)
if [[ -z "$DIRECTORY" ]]; then
DIRECTORY="$ARG"
fi
;;
esac
done
if [[ -z "$DIRECTORY" ]]; then
error "Missing directory"
echo "Usage: $0 <directory> [--dry-run] [--status] [VAR=value]"
exit 1
fi
# ----------------------------- HOST -----------------------------
detect_hosts