emasaka #7223(2008/08/19 13:24 GMT) [ Bash ] Rating0/0=0.00
pure bashで。最大1秒未満の誤差。
see: ゲームで極める シェルスクリプトスーパーテクニック
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
#!/bin/bash function InputChecker(){ local timeout=$1 local str=$2 echo -n "input($str) =>" read -n1 c t1=$SECONDS read s t=$(( $SECONDS - $t1 )) echo -n 'result => ' if (( $t >= $timeout )) ; then echo 'TIME OUT' elif [ "$c$s" == "$str" ] ; then echo 'OK' else echo 'NG' fi } InputChecker $1 $2 InputChecker $1 $2 InputChecker $1 $2
Rating0/0=0.00-0+
[ reply ]
emasaka #7223() [ Bash ] Rating0/0=0.00
pure bashで。最大1秒未満の誤差。
see: ゲームで極める シェルスクリプトスーパーテクニック
Rating0/0=0.00-0+
[ reply ]