feat: Add variable name_suffix; Pass shellcheck; Discard useless variables from main script
This commit is contained in:
@ -26,16 +26,17 @@ handler::tar() {
|
||||
local uri
|
||||
local src_path
|
||||
local dst_path
|
||||
local opts
|
||||
local archive
|
||||
local exclude
|
||||
local file_ext
|
||||
|
||||
uri="$1"
|
||||
# shellcheck disable=SC2154
|
||||
dst_path="$__main_target_path"
|
||||
|
||||
parse_uri "$uri"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
if [ -f "$path" ] || [ -d "$path" ]; then
|
||||
src_path="$path"
|
||||
else
|
||||
@ -51,15 +52,8 @@ handler::tar() {
|
||||
# Exit if tar is not installed
|
||||
is_installed tar
|
||||
|
||||
# Overwrire __tar_options
|
||||
if [ -n "$tar_options" ]; then
|
||||
opts="$tar_options"
|
||||
else
|
||||
opts="$__tar_options"
|
||||
fi
|
||||
|
||||
# Overwrite __tar_exclude
|
||||
if [ "$tar_exclude" ]; then
|
||||
# Set tar_exclude
|
||||
if [ -n "$tar_exclude" ]; then
|
||||
for item in "${tar_exclude[@]}"; do
|
||||
exclude+=" --exclude $item"
|
||||
done
|
||||
@ -67,6 +61,9 @@ handler::tar() {
|
||||
exclude=
|
||||
fi
|
||||
|
||||
# Set options
|
||||
tar_options="${tar_options:--acf}"
|
||||
|
||||
# Select filename extension by compression type.
|
||||
if [ "$compression" ]; then
|
||||
# Make sure for the `--auto-compress` is enabled in __tar_options
|
||||
@ -99,14 +96,14 @@ handler::tar() {
|
||||
[ "$__verbose" ] && {
|
||||
echo "Source path: $src_path"
|
||||
echo "Destination path: $dst_path"
|
||||
echo "Run command: tar $exclude $opts $archive $src_path"
|
||||
echo "Run command: tar $exclude $tar_options $archive $src_path"
|
||||
}
|
||||
|
||||
log "Archiving $src_path to $archive ..."
|
||||
log "Run command: tar $exclude $opts $archive $src_path"
|
||||
log "Run command: tar $exclude $tar_options $archive $src_path"
|
||||
|
||||
# Run tar
|
||||
try tar "$exclude" "$opts" "$archive" "$src_path"
|
||||
try tar "$exclude" "$tar_options" "$archive" "$src_path"
|
||||
|
||||
# Append path to 'backups' array
|
||||
backups+=("$archive")
|
||||
|
Reference in New Issue
Block a user