Augment daily todo template
[khome.git] / home / bin / dotnet-new-cleanup
1 #! /bin/sh
2
3 BOM='^\xef\xbb\xbf'
4
5 case "`uname`" in
6 Darwin)
7 _sed=gsed;
8 _grep=ggrep;;
9 *)
10 _sed=sed;
11 _grep=grep;;
12 esac
13
14 case "$1" in
15 '') _dir=.;;
16 *) _dir="$1";;
17 esac
18
19 _find() {
20 _pattern="$1"
21 LC_ALL=C "$_grep" \
22 --color=never \
23 -rIcP \
24 --exclude-dir=.git \
25 "$_pattern" "$_dir" \
26 | awk -F: '$2 {print $1}'
27 }
28
29 _delete() {
30 _pattern="$1"
31 while read _file
32 do
33 tmp="`mktemp`"
34 LC_ALL=C "$_sed" "s/$_pattern//" "$_file" > "$tmp"
35 mv "$tmp" "$_file"
36 done
37 }
38
39 echo 'BOM:'
40 echo '----'
41 _find "$BOM"
42
43 echo ''
44
45 echo 'Trailing carriage return:'
46 echo '-------------------------'
47 _find '\r'
48
49 case "$2" in
50 -delete)
51 _find '\r' | _delete '\r'
52 _find "$BOM" | _delete "$BOM"
53 ;;
54 *)
55 :;;
56 esac
This page took 0.100639 seconds and 4 git commands to generate.