#!/bin/bash # Library test script # Start by sourcing (reading in) the 'library.sh' file. source 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 { echon "$(boldon)Try again$(boldoff). Do you have echo " echon "in your path? (1=yes, 2=no) " read answer } # Is the command that checks what's in the path working? if ! checkForCmdInPath "echo" { echo "Nope, can't find the echo command." } else { echo "The echo command is in the PATH." } 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 { echon "Please enter a year in the $(boldon)correct$(boldoff) format: " read year } # Now test whether it was indeed a leap year. if isLeapYear $year { echo "$(greenf)You're right! $year was a leap year.$(reset)" } else { echo "$(redf)Nope, that's not a leap year.$(reset)" } exit 0