From: Steven Baltakatei Sandoval <baltakatei@gmail.com>
Date: Mon, 18 Mar 2024 18:40:21 +0000 (+0000)
Subject: feat(user/rsync_tranches):Handle option args
X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/97ff1ce0a12ba1018a81ca873a1e63a2049304cd

feat(user/rsync_tranches):Handle option args

- Note: Handle by assuming non-paths are option args
---

diff --git a/user/rsync_tranches.sh b/user/rsync_tranches.sh
index 0456daa..eed19f6 100644
--- a/user/rsync_tranches.sh
+++ b/user/rsync_tranches.sh
@@ -7,7 +7,7 @@ function rsync_tranches() {
     # Desc: Runs rsync in parallel across different files size ranges
     # Example: rsync_tranches -avu --progress --dry-run ./SOURCE/ ./DEST/
     # Depends: rsync 3.2.7
-    # Version: 0.0.3
+    # Version: 0.1.0
     local -a rsync_opts=();
     local source dest;
 
@@ -20,7 +20,13 @@ function rsync_tranches() {
                 shift;
                 ;;
             *)
-                if [ -z "$source" ]; then
+                ## If not a file or directory, assume option
+                if [[ ! -f "$1" ]] && [[ ! -d "$1" ]]; then
+                    rsync_opts+=("$1");
+                    shift;
+                fi;
+                ## If valid file or directory, assume source or dest path
+                if [[ -z "$source" ]]; then
                     source="$1";
                 else
                     dest="$1";