#! /bin/bash cd $1 for pch in ../*.patch; do printf "Applying patch %s...\n" "$pch" patch -Np1 < "$pch" | sed 's/^/--> /g' if [ "$?" == "0" ]; then printf "[OK] Applying patch %s [OK]\n" "$pch" else printf "[ERR!!!] Applying patch %s [ERR!!!]\n" "$pch" if [ "$2" != "skip" ]; then echo "assuming error is critical, aborting\n" exit 1 fi fi touch ../patch.ok done