-
Notifications
You must be signed in to change notification settings - Fork 0
/
12-library_test
43 lines (35 loc) · 1.1 KB
/
12-library_test
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
# Library test script
# Start by sourcing (reading in) the 'library.sh' file.
. library.sh
initializeANSI # Let's set up all those ANSI escape sequences.
# Test validint functionality.
echon "First off, do you have echo in your path? (1=yes, 2=no) "
read answer
while ! validint $answer 1 2 ; do
echon "${boldon}Try again${boldoff}. Do you have echo "
echon "in your path? (1=yes, 2=no) "
read answer
done
# Is the command that checks what's in the path working?
if ! checkForCmdInPath "echo" ; then
echo "Nope, can't find the echo command."
else
echo "The echo command is in the PATH."
fi
echo ""
echon "Enter a year you think might be a leap year: "
read year
# Test to see if the year specified is between 1 and 9999 by
# using validint with a min and max value.
while ! validint $year 1 9999 ; do
echon "Please enter a year in the ${boldon}correct${boldoff} format: "
read year
done
# Now test whether it was indeed a leap year.
if isLeapYear $year ; then
echo "${greenf}You're right! $year was a leap year.${reset}"
else
echo "${redf}Nope, that's not a leap year.${reset}"
fi
exit 0