blob: 0f1254e6533ff22299cd8134d4bc5c6ba738b575 [file] [log] [blame]
Ryan Harkinaef265c2012-08-13 17:47:46 +01001#!/bin/bash
2# Echos a string with a delay between each character
3# When a # character is encountered, it's replaced with a 1 second pause
4# and the # is NOT echoed out
5#
6# When there are no params:
7# - take stdin as the string
8# Where there is 1 param:
9# - take the contents of the file in param 1 as the string
10
11# Decide where to get the string
12if [ $# -eq 0 ]
13then
14 str=`cat`
15else
16 str=`cat $1`
17fi
18
19# Break the string into characters and echo them 1 at a time
20while [ -n "$str" ]
21 do
22# if [[ "${str:0:1}" = *$'\x0a'* ]]
23# then
24# printf "%c" "$str"
25# sleep 2
26# elif [[ "${str:0:1}" = *$'#'* ]]
27 if [[ "${str:0:1}" = *$'#'* ]]
28 then
29 sleep 1
30 else
31 printf "%c" "$str"
32 sleep 0.05
33 fi
34 str=${str#?}
35done
36printf "\n"
37