| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # ex59.sh: Exercising functions (simple). |
| 3 | |
| 4 | JUST_A_SECOND=1 |
| 5 | |
| 6 | funkyscip-shell shell abs-guide 10-4 funky(). () |
| 7 | { # This is about as simple as functions get. |
| 8 | echoscip-shell system . . echo. "This is a funky function." |
| 9 | echoscip-shell system . . echo. "Now exiting funky function." |
| 10 | } # Function declaration must precede call. |
| 11 | |
| 12 | |
| 13 | funscip-shell shell abs-guide 10-4 fun(). () |
| 14 | { # A somewhat more complex function. |
| 15 | i=0 |
| 16 | REPEATS=30 |
| 17 | |
| 18 | echoscip-shell system . . echo. |
| 19 | echoscip-shell system . . echo. "And now the fun really begins." |
| 20 | echoscip-shell system . . echo. |
| 21 | |
| 22 | sleepscip-shell system . . sleep. $JUST_A_SECOND # Hey, wait a second! |
| 23 | while [scip-shell system . . `[`. $i -lt $REPEATS ] |
| 24 | do |
| 25 | echoscip-shell system . . echo. "----------FUNCTIONS---------->" |
| 26 | echoscip-shell system . . echo. "<------------ARE-------------" |
| 27 | echoscip-shell system . . echo. "<------------FUN------------>" |
| 28 | echoscip-shell system . . echo. |
| 29 | let "i+=1" |
| 30 | done |
| 31 | } |
| 32 | |
| 33 | # Now, call the functions. |
| 34 | |
| 35 | funkyscip-shell shell abs-guide 10-4 funky(). |
| 36 | funscip-shell shell abs-guide 10-4 fun(). |
| 37 | |
| 38 | exit $? |