-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment1_package.sh
executable file
·89 lines (76 loc) · 2.16 KB
/
assignment1_package.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
#Title :assignment1_package.sh
#description :This script will package assignment1 for submission.
#Author :Swetank Kumar Saha <[email protected]>
#Version :1.0
#===================================================================================================
# https://gist.github.com/davejamesmiller/1965569
function ask {
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
# Ask the question
read -p "$1 [$prompt] " REPLY
# Default?
if [ -z "$REPLY" ]; then
REPLY=$default
fi
# Check if the reply is valid
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}
echo
echo -n "Enter your UBIT username (without the @buffalo.edu part) and press [ENTER]: "
read ubitname
if [ -d "./${ubitname}" ];
then
echo "Directory with given UBITname exists"
else
echo "No directory named ${ubitname} found. Try again!"
exit 0
fi
echo "Verifying contents ..."
echo
echo "C/C++ file with main function: "
FILE=`find ./$ubitname/src/ -name "${ubitname}_assignment1.c" -o -name "${ubitname}_assignment1.cpp"`
if [ -n "$FILE" ];
then
echo "File $FILE exists"
if grep -q "int main[ ]*([^\)]*)" $FILE
then
echo "File $FILE contains a 'int main()' function definition"
else
echo "File $FILE does NOT contain the 'int main()' function definition"
exit 0
fi
else
echo "Missing main C file or file named incorrectly!"
exit 0
fi
echo
echo "Makefile: "
FILE=./$ubitname/Makefile
if [ -f $FILE ];
then
echo "File $FILE exists"
else
echo "Missing Makefile or file named incorrectly!"
exit 0
fi
echo
echo "Packaging ..."
cd ${ubitname}/ && tar --exclude='./logs' -zcvf ../${ubitname}_pa1.tar * && cd ..
echo "Done!"
echo "IMPORTANT: Your submission is NOT done!"
echo "You need to use the submit_cse489/submit_cse589 (available on CSE servers) script to submit this tarball."