blob: 57646735e55baa3cbec8a2f0e333d6a417956442 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# line ending management script
# CRLF - windows default ('\r\n')
# LF - unix default ('\n')
# arguments:
# ?crlf - print all .cpp and .h files with CRLF line endings
# ?lf - print all .cpp and .h files with LF line endings
# crlf - replace line endings in all .cpp and .h files to CRLF
# lf - replace line endings in all .cpp and .h files to LF
if [ "$1" == "?crlf" ] || [ $# -eq 0 ]; then
echo 'cpp and h files with CRLF line endings:'
find {*.cpp,*.h} -not -type d -exec file "{}" ";" | grep CRLF | sed 's/:.*//g'
elif [ "$1" == "?lf" ]; then
echo 'cpp and h files with LF line endings:'
find {*.cpp,*.h} -not -type d -exec file "{}" ";" | grep -v CRLF | sed 's/:.*//g'
fi
if [ "$1" == "crlf" ]; then
echo 'replacing LF with CRLF in all cpp and h files:'
find {*.cpp,*.h} -not -type d -exec file "{}" ";" | grep -v CRLF | sed 's/:.*//g' | while read fn; do
echo "$fn"
sed -i 's/$/\r/g' $fn
done
elif [ "$1" == "lf" ]; then
echo 'replacing CRLF with LF in all cpp and h files:'
find {*.cpp,*.h} -not -type d -exec file "{}" ";" | grep CRLF | sed 's/:.*//g' | while read fn; do
echo "$fn"
sed -i 's/\r\n/\n/g' $fn
done
fi
|