Bash: crlf can check single file.
This commit is contained in:
parent
9108b2dc1b
commit
bb1d21345c
@ -152,13 +152,26 @@ function yay() {
|
||||
}
|
||||
|
||||
# Find files with Windows line endings (and convert then to Unix in force mode)
|
||||
# USAGE: crlf [--force]
|
||||
# USAGE: crlf [file] [--force]
|
||||
function crlf() {
|
||||
local force=
|
||||
|
||||
# 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
|
||||
grep -q $'\x0D' "$file" && echo "$file" && [ $force ] && dos2unix "$file"
|
||||
_crlf_file $file $force
|
||||
done
|
||||
}
|
||||
function _crlf_file() {
|
||||
grep -q $'\x0D' "$1" && echo "$1" && [ $2 ] && dos2unix "$1"
|
||||
}
|
||||
|
||||
# Backup remote MySQL database to ~/Backups/hostname/dbname_YYYY-MM-DD.sql.gz
|
||||
# USAGE: mysql-dump <ssh_hostname> <mysql_database> [mysql_username] [mysql_host]
|
||||
|
Loading…
Reference in New Issue
Block a user