-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-lab.sh
executable file
·51 lines (38 loc) · 1.41 KB
/
check-lab.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
#! /bin/bash
function die() {
echo "$@" >&2
exit 1
}
[ $# = 1 ] || die "You must specify a lab directory."
cd "$1" || die "No such directory: $1"
[ -f answers.txt ] || die "No answers.txt file!"
BOLD="`echo -ne \\\\033[1m`"
NORM="`echo -ne \\\\033[0m`"
ids=`grep "^Student ID:" answers.txt | sed -e 's/^[^:]*: *//' | grep .`
[ "$ids" = "" ] && die "
*** You have not yet filled out the answers.txt file!
*** Fill out the answers.txt file and try again.
"
echo
echo "Here's the information in your answers.txt file."
echo "Please make sure it is correct."
echo
echo "Your name(s):$BOLD"
grep "^Name:" answers.txt | sed -e 's/^[^:]*:[ ]*//' | grep . | sed -e 's/^/ /'
echo "$NORM"
echo "Your student ID(s):$BOLD"
grep "^Student ID:" answers.txt | sed -e 's/^[^:]*:[ ]*//' | grep . | sed -e 's/^/ /'
echo "$NORM"
echo "Your email address(es):$BOLD"
grep "^Email:" answers.txt | sed -e 's/^[^:]*:[ ]*//' | grep . | sed -e 's/^/ /'
echo "$NORM"
grep "^Extra credit problem:" answers.txt >/dev/null 2>&1 && EXTRA="yes; `grep "^Extra credit problem:" answers.txt | cut -d: -f 2- | sed -e 's/^[ ]*//'`" || EXTRA="no"
echo "Extra credit problem(s): $BOLD$EXTRA$NORM"
echo
echo -n "Is all this information correct? [y/N] "
read LINE
echo
[ "$LINE" == "y" -o "$LINE" == "Y" ] || die "Please correct the answers.txt file and try again."
echo "*** Thank you. Please submit the file $BOLD$1.tar.gz$NORM
*** to only one CourseWeb account.
"