feat: Code improvements
This commit is contained in:
parent
5310d5ae0f
commit
c2dc7a0729
@ -22,14 +22,10 @@ __verbose=
|
||||
__log_file='./log.txt'
|
||||
__log_date_fmt='%d/%b/%Y:%H:%M:%S %z'
|
||||
__tar_options='-acf'
|
||||
__tar_compression='gzip'
|
||||
__tar_exclude=
|
||||
__name_date_fmt='_%Y%m%d-%H%M'
|
||||
|
||||
if [ -n "$BBLIB" ]; then
|
||||
__library="$BBLIB"
|
||||
else
|
||||
__library='./lib'
|
||||
fi
|
||||
__compression='gzip'
|
||||
__library="${BBLIB:-./lib}"
|
||||
|
||||
# Source library
|
||||
for file in "$__library"/*; do
|
||||
@ -125,21 +121,23 @@ log "Scripts to process (${__count}): ${__args[@]}"
|
||||
|
||||
|
||||
for script in "${__args[@]}"; do
|
||||
# Initialise variables
|
||||
__user_script="$script"
|
||||
backups=() # Array of created backups, contains full pathes
|
||||
errors=() # Array of error messages written by err() function
|
||||
|
||||
# Source scripts
|
||||
source_script "$script"
|
||||
|
||||
# Config can ovewrite script functions and variables
|
||||
[ -n "$__config" ] && . "$__config"
|
||||
|
||||
echo
|
||||
echo -e "\e[1m==> Script: ${__args[__iter-1]##*/} [$__iter/$__count]\e[0m" | log -p
|
||||
|
||||
# Initialise variables
|
||||
__user_script="$script"
|
||||
backups=() # Array of created backups, contains full pathes
|
||||
echo -e "\e[1m--> Script: ${__args[__iter-1]##*/} [$__iter/$__count]\e[0m" | log -p
|
||||
|
||||
# Run prepare() before all if set
|
||||
if is_function_set prepare; then
|
||||
log -p "Execute prepare() ..."
|
||||
echo -e "Execute \e[1mprepare()\e[0m ..." | log -p
|
||||
prepare
|
||||
unset prepare
|
||||
fi
|
||||
@ -165,8 +163,9 @@ for script in "${__args[@]}"; do
|
||||
((__iter++)) || true
|
||||
|
||||
# Unset user defined variables
|
||||
unset compression
|
||||
unset tar_options
|
||||
unset tar_compression
|
||||
unset tar_exclude
|
||||
unset name_date_fmt
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user