#!/usr/bin/env bash find 'vendor_patches' -name '*.patch' | sort | while read f; do # If we could reverse the patch, then it has already been applied; skip it if patch --dry-run --reverse --force -p0 -N -i "$f" >/dev/null 2>&1; then echo -e "\e[32m[i] Patch \"$f\" already applied - skipping.\e[m" >&2 else # patch not yet applied echo -e "\e[33m[i] Applying patch \"$f\"...\e[m" patch -p0 -N -i "$f" || echo -e "\e[31;1mPatch \"$f\" failed\e[m" >&2 fi #patch -p0 -N -i "$f" done; echo "Patches applied."