- [ -n "$timeout" ] || timeout=1
- [ $timeout -ge 1 ] || timeout=1
- timer=$timeout
- lock $keypress_wait
- {
- while [ $timer -gt 0 ]; do
- echo "$timer" >$keypress_sec
- timer=$(($timer - 1))
- sleep 1
- done
- lock -u $keypress_wait
- rm -f $keypress_wait
- } &
-
- echo "Press the [$1] key and hit [enter] $2"
- echo "Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level"
- # if we're on the console we wait for input
- {
- while [ -r $keypress_wait ]; do
- timer="$(cat $keypress_sec)"
-
- [ -n "$timer" ] || timer=1
- timer="${timer%%\ *}"
- [ $timer -ge 1 ] || timer=1
- do_keypress=""
- {
- read -t "$timer" do_keypress
- case "$do_keypress" in
- $1)
- echo "true" >$keypress_true
- ;;
- 1 | 2 | 3 | 4)
- echo "$do_keypress" >/tmp/debug_level
- ;;
- *)
- continue;
- ;;
- esac
+ [ -n "$timeout" ] || timeout=1
+ [ $timeout -ge 1 ] || timeout=1
+ timer=$timeout
+ lock $keypress_wait
+ {
+ while [ $timer -gt 0 ]; do
+ echo "$timer" >$keypress_sec
+ timer=$(($timer - 1))
+ sleep 1
+ done