From 256186376d2dadb48ce6eafded42f2eb623f0386 Mon Sep 17 00:00:00 2001 From: "kebler.net" Date: Thu, 18 Feb 2021 07:31:28 -0800 Subject: [PATCH] refactor cprs (rsync) for ACL and using sudo --- alias/acl | 2 +- function/rsync | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/alias/acl b/alias/acl index 000ace8..5cad5c8 100644 --- a/alias/acl +++ b/alias/acl @@ -1 +1 @@ -alias aud="acluserdir" \ No newline at end of file +alias aud="acladduserdir" \ No newline at end of file diff --git a/function/rsync b/function/rsync index f110fae..f4dc501 100755 --- a/function/rsync +++ b/function/rsync @@ -3,11 +3,14 @@ # present working directory to supplied destination module_load confirm function cprs () { + local usesudo + local cmd + [[ $1 == "-s" ]] && usesudo='sudo' && shift [ $# -ne 2 ] && echo two directories source and destination need to be passed && return 1 [ ! -d "$1" ] && echo source: $1 is not a directory && return 1 - [ ! -d "$2" ] && echo destination: $2 is not a directory && return 1 - echo Command to run: rsync --progress -a -r -u "$1" "$2" + cmd="$usesudo rsync --exclude *[C]ache* --exclude node_modules --progress -aAru $1 $2" + echo $cmd confirm Do you want to start the rsync copy? || return 0 echo copying..... - rsync --exclude *[C]ache* --progress -a -r -u "$1" "$2" + eval $cmd }