URI: 
   DIR <- Back
       
       bsleep - Breakable Sleep
       ========================
       
       bsleep is a sleep that breaks as soon as you press 'b'.
       It makes clever use of the -t (timeout) and -n (read n bytes) parameters
       of the bash built-in: read.
       
       bsleep can be used to quickly test something and chain a quick undo
       command right after you initial command.
       
       example usage:
             echo "do something"; bsleep; echo "quickly undo"
       
       The other day I was tinkering with an iptables ruleset and needed exactly
       that. So quickly hacked it quick'n'dirty (originally as a one-liner).
       
       The Bash-Shellfunction:
       
             function bsleep () {
                     local c=1;
                     local INPUT;
                     while [ ! "$INPUT" == "b" ]; do
                             printf "$c "; # comment out if you prefer silent
                             c=$(($c+1));
                             read -s -n1 -t1 INPUT;
                     done;
                     printf "\n";
             }
       
       
       
                                     z
                                    z
                                     Z
                           .--.  Z Z
                          / _(c\   .-.     __
                         | / /  '-;   \'-'`  `\______
                         \_\/'/ __/ )  /  )   |      \--,
                         | \`""`__-/ .'--/   /--------\  \
                          \\`  ///-\/   /   /---;-.    '-'
                    jgs                (________\  \
                                                 '-'
       
  HTML asciinema
       
       
       P.S.:
       In general I strife to get rid of bashisms in my daily doing. I noticed
       that the built-in read functions of some POSIX shells (e.g. like ksh) do
       not provide -t or -n.
       So I aim to write a little bsleep-program in C in the future.
       
       Update:
   DIR 2024-06-30 - bsleep (rewritten in C)