mirror of https://github.com/tLDP/LDP
97 lines
1.9 KiB
Bash
97 lines
1.9 KiB
Bash
#!/bin/bash
|
|
# homework.sh: All-purpose homework assignment solution.
|
|
# Author: M. Leo Cooper
|
|
# If you substitute your own name as author, then it is plagiarism,
|
|
#+ possibly a lesser sin than cheating on your homework!
|
|
# License: Public Domain
|
|
|
|
# This script may be turned in to your instructor
|
|
#+ in fulfillment of ALL shell scripting homework assignments.
|
|
# It's sparsely commented, but you, the student, can easily remedy that.
|
|
# The script author repudiates all responsibility!
|
|
|
|
DLA=1
|
|
P1=2
|
|
P2=4
|
|
P3=7
|
|
PP1=0
|
|
PP2=8
|
|
MAXL=9
|
|
E_LZY=99
|
|
|
|
declare -a L
|
|
L[0]="3 4 0 17 29 8 13 18 19 17 20 2 19 14 17 28"
|
|
L[1]="8 29 12 14 18 19 29 4 12 15 7 0 19 8 2 0 11 11 24 29 17 4 6 17 4 19"
|
|
L[2]="29 19 7 0 19 29 8 29 7 0 21 4 29 13 4 6 11 4 2 19 4 3"
|
|
L[3]="19 14 29 2 14 12 15 11 4 19 4 29 19 7 8 18 29"
|
|
L[4]="18 2 7 14 14 11 22 14 17 10 29 0 18 18 8 6 13 12 4 13 19 26"
|
|
L[5]="15 11 4 0 18 4 29 0 2 2 4 15 19 29 12 24 29 7 20 12 1 11 4 29"
|
|
L[6]="4 23 2 20 18 4 29 14 5 29 4 6 17 4 6 8 14 20 18 29"
|
|
L[7]="11 0 25 8 13 4 18 18 27"
|
|
L[8]="0 13 3 29 6 17 0 3 4 29 12 4 29 0 2 2 14 17 3 8 13 6 11 24 26"
|
|
L[9]="19 7 0 13 10 29 24 14 20 26"
|
|
|
|
declare -a \
|
|
alph=( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z . , : ' ' )
|
|
|
|
|
|
pt_lt ()
|
|
{
|
|
echo -n "${alph[$1]}"
|
|
echo -n -e "\a"
|
|
sleep $DLA
|
|
}
|
|
|
|
b_r ()
|
|
{
|
|
echo -e '\E[31;48m\033[1m'
|
|
}
|
|
|
|
cr ()
|
|
{
|
|
echo -e "\a"
|
|
sleep $DLA
|
|
}
|
|
|
|
restore ()
|
|
{
|
|
echo -e '\033[0m' # Bold off.
|
|
tput sgr0 # Normal.
|
|
}
|
|
|
|
|
|
p_l ()
|
|
{
|
|
for ltr in $1
|
|
do
|
|
pt_lt "$ltr"
|
|
done
|
|
}
|
|
|
|
# ----------------------
|
|
b_r
|
|
|
|
for i in $(seq 0 $MAXL)
|
|
do
|
|
p_l "${L[i]}"
|
|
if [[ "$i" -eq "$P1" || "$i" -eq "$P2" || "$i" -eq "$P3" ]]
|
|
then
|
|
cr
|
|
elif [[ "$i" -eq "$PP1" || "$i" -eq "$PP2" ]]
|
|
then
|
|
cr; cr
|
|
fi
|
|
done
|
|
|
|
restore
|
|
# ----------------------
|
|
|
|
echo
|
|
|
|
exit $E_LZY
|
|
|
|
# A typical example of an obfuscated script that is difficult
|
|
#+ to understand, and frustrating to maintain.
|
|
# In your career as a sysadmin, you'll run into these critters
|
|
#+ all too often.
|