refactor way list command functions

master
David Kebler 2024-10-17 12:33:40 -07:00
parent 263ba5296d
commit fb7c510d2b
1 changed files with 12 additions and 5 deletions

View File

@ -203,18 +203,25 @@ EOF
[[ $Mirror ]] && args+=(--delete-excluded)
[[ ! -v PS1 ]] && noconfirm=true
if [[ ! $noconfirm && ! $list ]]; then
cmd="$usesudo $(which rsync) ${args[*]} $SRC$([[ $insert ]] && echo "/") $DEST"
[[ $list ]] && echo "$cmd"
if [[ ! $noconfirm ]]; then
if [[ $insert ]]; then
# todo mirror option
confirm The contents within $([[ $SHOST ]] && echo $SHOST:)$SPATH will be \
$([[ $mirror ]] && echo mirrored || echo placed ) inside $([[ $DHOST ]] && echo $DHOST:)$DPATH || return 0
else
confirm the directory $(basename $SPATH) of $([[ $SHOST ]] && echo $SHOST:)$SPATH will be \
$([[ $mirror ]] && echo mirrored || echo put ) at destination $([[ $DHOST ]] && echo $DHOST:)$DPATH/$(basename $SPATH)? || return 0
$([[ $mirror ]] && echo mirrored || echo put ) at destination $([[ $DHOST ]] && echo $DHOST:)$DPATH/$(basename $SPATH) || return 0
fi
fi
cmd="$usesudo $(which rsync) ${args[*]} $SRC$([[ $insert ]] && echo "/") $DEST"
[[ $list ]] && echo "$cmd" && return 0
if [[ $list && ! $noconfirm ]]; then
confirm list command during dry run, do you want to continue with dry run || return 0
fi
if [[ ! $quiet ]]; then [[ $exec ]] && echo executing the copy command || echo dry run of command, use -r to execute; fi
if eval $cmd; then
[[ ! $quiet ]] && echo copy success!
@ -224,7 +231,7 @@ EOF
>&2 echo $cmd
return 1
fi
}
}
alias fcpy="copy -r -q -i -n -a "