Last active
January 23, 2019 13:25
-
-
Save jschnasse/27494d5cd2dd969ba659dd169eb97edf to your computer and use it in GitHub Desktop.
a bash script to demonstrate bash input and output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function readCommand(){ | |
lastCommand=$1 | |
read -t.1 -n1 c; | |
if [ "$c" = "p" ] | |
then | |
printf "\n\r"; | |
return 0 | |
fi | |
if [ "$c" = "g" ] | |
then | |
printf "\n\r"; | |
return 1 | |
fi | |
return $lastCommand | |
} | |
function spin(){ | |
for i in / - \\ \| ; | |
do | |
printf "\r$i"; | |
sleep .1; | |
done | |
} | |
function countUp(){ | |
currentCount=$1 | |
return `expr $currentCount + 1` | |
} | |
function counter(){ | |
countUp $count | |
count=$? | |
printf "\r$count" | |
sleep .1; | |
} | |
command=1 | |
count=0 | |
while : | |
do | |
if [[ $command == 1 ]] | |
then | |
spin | |
fi | |
readCommand $command | |
command=$? | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment