mirror of https://github.com/tLDP/LDP
39 lines
659 B
Bash
39 lines
659 B
Bash
#!/bin/bash
|
|
# ex59.sh: Exercising functions (simple).
|
|
|
|
JUST_A_SECOND=1
|
|
|
|
funky ()
|
|
{ # This is about as simple as functions get.
|
|
echo "This is a funky function."
|
|
echo "Now exiting funky function."
|
|
} # Function declaration must precede call.
|
|
|
|
|
|
fun ()
|
|
{ # A somewhat more complex function.
|
|
i=0
|
|
REPEATS=30
|
|
|
|
echo
|
|
echo "And now the fun really begins."
|
|
echo
|
|
|
|
sleep $JUST_A_SECOND # Hey, wait a second!
|
|
while [ $i -lt $REPEATS ]
|
|
do
|
|
echo "----------FUNCTIONS---------->"
|
|
echo "<------------ARE-------------"
|
|
echo "<------------FUN------------>"
|
|
echo
|
|
let "i+=1"
|
|
done
|
|
}
|
|
|
|
# Now, call the functions.
|
|
|
|
funky
|
|
fun
|
|
|
|
exit $?
|