You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
601 B
25 lines
601 B
#!/usr/bin/env bash
|
|
|
|
# Find files with Windows line endings (and convert them to Unix in force mode)
|
|
#
|
|
# Usage:
|
|
# crlf [file] [--force]
|
|
|
|
local force=
|
|
|
|
function _crlf_file() {
|
|
grep -q $'\x0D' "$1" && echo "$1" && [ $2 ] && dos2unix "$1"
|
|
}
|
|
|
|
# Single file
|
|
if [ "$1" != "" ] && [ "$1" != "--force" ]; then
|
|
[ "$2" == "--force" ] && force=1 || force=0
|
|
_crlf_file $1 $force
|
|
return
|
|
fi
|
|
|
|
# All files
|
|
[ "$1" == "--force" ] && force=1 || force=0
|
|
for file in $(find . -type f -not -path "*/.git/*" -not -path "*/node_modules/*" | xargs file | grep ASCII | cut -d: -f1); do
|
|
_crlf_file $file $force
|
|
done
|
|
|