install_file() {
    mode="$1"
    owner="$2"
    group="$3"
    path="$4"

    if [ "$DRY" = 'YES' ]; then
        before_mode_stat="$(stat -f '%p' "$path" 2>/dev/null || echo '????')"
        before_mode_prefix="${before_mode_stat%????}"
        before_mode="${before_mode_stat#"$before_mode_prefix"}"
        before_mode_user_group="$(stat -f '%Su %Sg' "$path" 2>/dev/null || echo '???? ????')"

        before_cmp="$before_mode $before_mode_user_group"
        after_cmp="$mode $owner $group"

        before="$before_cmp $path"
        after="$after_cmp $path"

        old="$path"
        new="$REPO$path"
    else
        before="$(ls -dl "$path" 2>&1 || true)"
        install -b -m "$mode" -o "$owner" -g "$group" "$REPO$path" "$path"
        after="$(ls -dl "$path" 2>&1)"

        before_cmp="$(echo "$before" | awk '{ print $1 " " $2 " " $3 " " $4 }')"
        after_cmp="$(echo  "$after"  | awk '{ print $1 " " $2 " " $3 " " $4 }')"

        old="$path.old"
        new="$path"
    fi

    changed=''
    diffed=''
    if [ "$before_cmp" != "$after_cmp" ]; then
        changed='YES'
    fi
    if [ -f "$old" ]; then
        if ! diff "$old" "$new" >/dev/null 2>/dev/null; then
            changed='YES'
            diffed='YES'
        fi
    fi

    if [ "$changed" = 'YES' ]; then
        echo '==='
        echo "$before"
        echo "$after"

        if [ "$diffed" = 'YES' ]; then
            echo '---'
            diff "$old" "$new" || true
        fi
    fi
}
