#! /bin/bash export TMPDIR=. for i in "$@"; do echo "====== applying ${i##*/} =========" patch --dry-run -Np1 < "$i" 2>&1 | awk '/^patching/ { st=0; file=$3; }; /^Hunk.*fuzz 2/ { print " " $2 " at " $5 FS $7 FS $8 FS $9 FS $10 FS $11 " -- " file; }; /saving rejects/ { print " " $6 FS $1 FS $2 FS $3 FS $4 FS $5 " -- " file; }; /^can.t find/ { print " " $0; }; /malformed patch/ { print " " $3 FS $4 FS $5 FS $6 FS $7 " -- " file; }' patch -Nsp1 < "$i" >/dev/null # workaround for a bug encountered when /tmp is on reiserfs and where # calling patch a lot of times finally makes it report ENOSPC ! # sync done