Check files for DOS/Windows line endings.
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 bash | |
# ----------- | |
# Check files for DOS/Windows line endings. | |
# ----------- | |
[ -a "$1" ] || { | |
echo 'Check files for DOS/Windows line endings.' | |
echo "Usage: ${0##*/} {filename}" | |
exit 0 | |
} | |
which dos2unix > /dev/null || { | |
echo 'This script requires dos2unix. Please run: sudo apt install dos2unix' | |
exit 2 | |
} | |
dos2unix < $1 | cmp -s - $1; | |
[ $? -ne 0 ] && { | |
echo "- $1 has DOS/Windows line endings" | |
exit 1 | |
} | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment