Last active
September 25, 2019 15:18
-
-
Save miguelortizdev/522a182d7cafee8e106a4ac7aa0e8f63 to your computer and use it in GitHub Desktop.
UTF-8 validation files for multiple character set projects
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 | |
| # Se define la lista de patrones incluidos para validación | |
| PATHS='composer.json' | |
| if [ -f .gitcharset ] ; then | |
| PATHS="$PATHS|`sed ':a;N;$!ba;s/\n/|/g' .gitcharset`" | |
| fi | |
| # Se recore cada uno de los ficheros incluidos para el compromiso y se validan unicamente aquellos que cumplan la expresión definida en el $PATH | |
| git diff --staged --name-only -- | egrep $PATHS | | |
| xargs -e sh -c ' | |
| e="" | |
| for f; do | |
| if ! iconv -f UTF-8 -t UTF-8 $f >/dev/null 2>&1; then | |
| e=1 | |
| echo "Not UTF-8: $f" | |
| fi | |
| done | |
| test -z "$e" | |
| ' - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment