-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcleaner.sh
More file actions
executable file
·40 lines (34 loc) · 763 Bytes
/
Copy pathcleaner.sh
File metadata and controls
executable file
·40 lines (34 loc) · 763 Bytes
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
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# This a simple bash script to run `cargo clean` recursively.
#
# Usage: `bash cargo-clean.sh target_dir`
clean_recursive() {
# First, check whether current directiry is the root of a cargo project.
if [ -f "Cargo.toml" ]; then
echo "Cleaning \"$(pwd)\""
cargo clean
fi
# Then, visit the sub directory.
for path in `ls`; do
if [ -d $path ]; then
cd $path
clean_recursive
cd ..
fi
done
}
main() {
if [ x$1 != x ]; then
if [ -d $1 ]; then
cd $1
else
echo "Error: $1 is not a directory, done."
fi
else
cd .
fi
echo "Scanning \"$(pwd)\""
clean_recursive
echo "Done."
}
main $*