feat(user/rsync_tranches):Handle option args
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Mon, 18 Mar 2024 18:40:21 +0000 (18:40 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Mon, 18 Mar 2024 18:40:21 +0000 (18:40 +0000)
- Note: Handle by assuming non-paths are option args

user/rsync_tranches.sh

index 0456daa30969ba2dc09135088ae80bc78896046f..eed19f652770dba289925aa33b0dc49057fbd938 100644 (file)
@@ -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";