Note why I chose 'rm -rf' instead of 'cargo clean'
[khome.git] / home / bin / dotnet-new-cleanup
CommitLineData
c35dfd6a
SK
1#! /bin/sh
2
3BOM='^\xef\xbb\xbf'
4
5case "`uname`" in
6 Darwin)
7 _sed=gsed;
8 _grep=ggrep;;
9 *)
10 _sed=sed;
11 _grep=grep;;
12esac
13
14case "$1" in
15 '') _dir=.;;
16 *) _dir="$1";;
17esac
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
c35dfd6a
SK
39echo 'BOM:'
40echo '----'
41_find "$BOM"
c35dfd6a
SK
42
43echo ''
44
45echo 'Trailing carriage return:'
46echo '-------------------------'
47_find '\r'
57b370f0
SK
48
49case "$2" in
50 -delete)
51 _find '\r' | _delete '\r'
52 _find "$BOM" | _delete "$BOM"
53 ;;
54 *)
55 :;;
56esac
This page took 0.086097 seconds and 4 git commands to generate.