initial commit
This commit is contained in:
46
chapter4/function_rotate
Executable file
46
chapter4/function_rotate
Executable file
@@ -0,0 +1,46 @@
|
||||
function rotate
|
||||
{
|
||||
# PURPOSE: This function is used to give the end user
|
||||
# some feedback that "something" is running. It gives
|
||||
# a line rotating in a circle. This function is started
|
||||
# as a background process. Assign its PID to a variable
|
||||
# using
|
||||
# rotate & # To start
|
||||
# ROTATE_PID=$! # Get the PID of the last
|
||||
# # background job
|
||||
#
|
||||
# At the end of execution just break out by
|
||||
# killing the $ROTATE_PID process. We also need
|
||||
# to do a quick "cleanup" of the leftover line of
|
||||
# rotate output.
|
||||
#
|
||||
# FROM THE SCRIPT:
|
||||
# kill -9 $ROTATE_PID
|
||||
# echo "\b\b "
|
||||
|
||||
INTERVAL=1 # Sleep time between rotation intervals
|
||||
RCOUNT="0" # For each RCOUNT the line rotates 1/8
|
||||
# cycle
|
||||
|
||||
while : # Loop forever...until this function is killed
|
||||
do
|
||||
(( RCOUNT = RCOUNT + 1 )) # Increment the RCOUNT
|
||||
|
||||
case $RCOUNT in
|
||||
1) echo .-."\b\c"
|
||||
sleep $INTERVAL
|
||||
;;
|
||||
2) echo .\\."\b\c"
|
||||
sleep $INTERVAL
|
||||
;;
|
||||
3) echo "|\b\c"
|
||||
sleep $INTERVAL
|
||||
;;
|
||||
4) echo "/\b\c"
|
||||
sleep $INTERVAL
|
||||
;;
|
||||
*) RCOUNT="0" # Reset the RCOUNT to "0", zero.
|
||||
;;
|
||||
esac
|
||||
done
|
||||
} # End of Function - rotate
|
||||
Reference in New Issue
Block a user