Last active
January 23, 2018 19:03
-
-
Save dnephin/a85bcc7f3c39ce258139b39cbdf960b5 to your computer and use it in GitHub Desktop.
Bash multi-line replace t.Error; return -> t.Fatal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
set -eu -o pipefail | |
git grep -A 1 '\st\.Error' | \ | |
grep 'return$' -B 2 | \ | |
cut -f1 | \ | |
grep -v -- '--' | | |
sed 's/.$//' | \ | |
sort | \ | |
uniq | while read filename; do | |
echo "$filename" | |
cat "$filename" | \ | |
tr '\n' '\r' | \ | |
sed -e 's/t.Error\([^\r]\+\)\r[[:blank:]]\+return\r/t.Fatal\1\r/g' | \ | |
tr '\r' '\n' > t; mv t "$filename" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment