add make_target_dirs
This commit is contained in:
		@@ -82,9 +82,20 @@ validate_targets() {
 | 
			
		||||
        __main_target="${file_targets[0]}"
 | 
			
		||||
        # Fail if __main_target's path is not a directory
 | 
			
		||||
        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
 | 
			
		||||
        if [ -d "$path" ]; then
 | 
			
		||||
            __main_target_path="$path"
 | 
			
		||||
            :
 | 
			
		||||
        else
 | 
			
		||||
            echo "Error: $backup_script:" \
 | 
			
		||||
                "Path '$path' from URI '$__main_target'" \
 | 
			
		||||
@@ -101,6 +112,8 @@ source_script() {
 | 
			
		||||
 | 
			
		||||
    local script="$1"
 | 
			
		||||
 | 
			
		||||
    script="$(realpath "$script")" || true
 | 
			
		||||
 | 
			
		||||
    if ! test -f "$script"; then
 | 
			
		||||
        echo "Error: No such file: $script" >&2; exit 1
 | 
			
		||||
    fi
 | 
			
		||||
@@ -112,7 +125,7 @@ source_script() {
 | 
			
		||||
 | 
			
		||||
    # Source script
 | 
			
		||||
    # shellcheck disable=SC1090
 | 
			
		||||
    if ! . "$(realpath "$script")"; then
 | 
			
		||||
    if ! . "$script"; then
 | 
			
		||||
        echo "Error: Cannot source script: $script" >&2; exit 1;
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user