add make_target_dirs

This commit is contained in:
ge 2022-10-08 19:39:07 +03:00
parent b53cc39495
commit 340d353b78

View File

@ -82,9 +82,20 @@ validate_targets() {
__main_target="${file_targets[0]}" __main_target="${file_targets[0]}"
# Fail if __main_target's path is not a directory # Fail if __main_target's path is not a directory
parse_uri "$__main_target" parse_uri "$__main_target"
__main_target_path="$path"
# Make dirs if `make_target_dir` is set
if [ -n "$make_target_dir" ]; then
for file_target in "${file_targets[@]}"; do
parse_uri "$file_target"
mkdir -p "$path"
done
return 0
fi
# shellcheck disable=SC2154 # shellcheck disable=SC2154
if [ -d "$path" ]; then if [ -d "$path" ]; then
__main_target_path="$path" :
else else
echo "Error: $backup_script:" \ echo "Error: $backup_script:" \
"Path '$path' from URI '$__main_target'" \ "Path '$path' from URI '$__main_target'" \
@ -101,6 +112,8 @@ source_script() {
local script="$1" local script="$1"
script="$(realpath "$script")" || true
if ! test -f "$script"; then if ! test -f "$script"; then
echo "Error: No such file: $script" >&2; exit 1 echo "Error: No such file: $script" >&2; exit 1
fi fi
@ -112,7 +125,7 @@ source_script() {
# Source script # Source script
# shellcheck disable=SC1090 # shellcheck disable=SC1090
if ! . "$(realpath "$script")"; then if ! . "$script"; then
echo "Error: Cannot source script: $script" >&2; exit 1; echo "Error: Cannot source script: $script" >&2; exit 1;
fi fi