Skip to content

Instantly share code, notes, and snippets.

@jschnasse
Last active January 23, 2019 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jschnasse/27494d5cd2dd969ba659dd169eb97edf to your computer and use it in GitHub Desktop.
Save jschnasse/27494d5cd2dd969ba659dd169eb97edf to your computer and use it in GitHub Desktop.
a bash script to demonstrate bash input and output
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