mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 16:58:02 +00:00
b088086b06
Now, it's all under the notebook umbrella. Seems to be appropriate as it is just my notes after all. I also updated some notes from there. I didn't keep track of what it is this time. Something about more learning notes extracted from my "Learning how to learn" course notes and then some. Lack of time and hurriness just makes it difficult to track but it should be under version control already.
31 lines
614 B
Bash
Executable File
31 lines
614 B
Bash
Executable File
#/usr/bin/env bash
|
|
set -eo pipefail
|
|
|
|
function help() {
|
|
echo "Usage: leap.sh <year>"
|
|
}
|
|
trap 'help' ERR
|
|
|
|
if test $# -lt 1 || test $# -gt 1
|
|
then
|
|
help && exit 1
|
|
fi
|
|
|
|
year=$1
|
|
|
|
# This is a check whether the input is a year.
|
|
# The year is expected to be an integer and printf throws an error if the specifier does not match the input.
|
|
# Pretty odd way but it is clever, don't you think?
|
|
printf "%d" $year 1>/dev/null 2>/dev/null
|
|
|
|
if test $(expr $year % 4) -eq 0
|
|
then
|
|
if test $(expr $year % 100) -eq 0 && test $(expr $year % 400) -ne 0
|
|
then
|
|
echo "false"
|
|
exit 0
|
|
fi
|
|
echo "true"
|
|
else echo "false"
|
|
fi
|