-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat-check.sh
43 lines (39 loc) · 1.02 KB
/
format-check.sh
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
40
41
42
43
#!/bin/bash
error=0
dirs=$(ls -l ./ |awk '/^d/ {print $NF}')
for dir in $dirs; do
temp=$(echo $dir | grep "^ex[0-9][0-9]*$")
if [ -n "$temp" ]; then
echo Directory $dir detected!
cd $dir
files=$(ls ./)
exfile=0
for file in $files; do
cfile=$(echo $file | grep "^$dir.c$")
if [ -n "$cfile" ]; then
echo C Source file $file found.
exfile=1
fi
cxxfile=$(echo $file | grep "^$dir.cpp$")
if [ -n "$cxxfile" ]; then
echo C++ Source file $file found.
exfile=1
fi
done
if [ $exfile == 0 ]; then
echo Error: No Source file found in $dir.
error=1
fi
cd ..
else
echo Error: Directory $dir invalid.
error=1
fi
echo
done
if [ $error == 0 ]; then
echo Congratulations! All tests passed.
else
echo Error found. Please check your files again!
fi
read -p "Press any key to continue."