1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#!/bin/sh
#
# saytime.sh - shell version of saytime, by david@eng.sun.com
SDIR=${1-${SAYTIME-.}}
SAYFILES=
# n leadingzero
saynumber () {
num=$1
zero=$2
set -$- `expr $num / 10 ; expr $num % 10`
tens=$1
unit=$2
case $tens in
0)
case $zero in
y) say oh ;;
esac
saydigit $unit
;;
1)
say $num
;;
*)
say ${tens}0
saydigit $unit
esac
}
saydigit () {
case $1 in
[1-9]) say $1 ;;
esac
}
say () {
file=$SDIR/$1.au
if [ ! -f $file ] ; then
echo "`basename $0`: cannot find $file"
exit 1
fi
SAYFILES="$SAYFILES $file"
}
say the_time_is
set -$- `/bin/date '+%H %M %S'`
h=$1 m=$2 s=$3
case $h in
0) h=12 ;;
1[3-9]|2[0-3]) h=`expr $h - 12` ;;
esac
saynumber $h n
case $m in
00) say oclock ;;
*) saynumber $m y
esac
case $s in
00) say exactly ;;
01) say and
saynumber $s n
say second
;;
*) say and
saynumber $s n
say seconds
esac
cat $SAYFILES > /dev/audio
|