Created
April 10, 2013 15:05
-
-
Save dantleech/5355412 to your computer and use it in GitHub Desktop.
Exception message reformatting script
This file contains hidden or 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
| #!/bin/bash | |
| FILES=`find ./src/Symfony -name "*.php"` | |
| OPTS=-i.bak | |
| git reset --hard | |
| # Fix 'This is '.$an.' exception '.$ok.' foo '.$bar | |
| perl $OPTS -pe "s/throw new (.*)Exception\('(.*?)'\.(.*?)\.'(.*?)'\.(.*?)\.'(.*?)'\.([^']*?)\);/throw new \1Exception\(sprintf\('\2%s\4%s\6%s', \3, \5, \7\)\);/g" $FILES | |
| # Fix 'This is '.$an.' exception '.$ok | |
| perl $OPTS -pe "s/throw new (.*)Exception\('(.*?)'\.(.*?)\.'(.*?)'\.([^']*?)\);/throw new \1Exception\(sprintf\('\2%s\4%s', \3, \5\)\);/g" $FILES | |
| # Fix 'This is '.$an.' foo' | |
| perl $OPTS -pe "s/throw new (.*)Exception\('(.*?)'\.(.*?)\.'(.*?)'\);/throw new \1Exception\(sprintf\('\2%s\4', \3\)\);/g" $FILES.' foo' | |
| # Fix 'This is '.$an | |
| perl $OPTS -pe "s/throw new (.*)Exception\('(.*?)'\.([^']*?)\);/throw new \1Exception\(sprintf\('\2%s', \3\)\);/g" $FILES | |
| rm `find ./src/Symfony -name "*.bak"` | |
| grep -Rn 'throw new ' | grep -v "sprintf" | grep "'\." | wc -l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment