add timeout to interactive example

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-06-03 13:28:29 +02:00
parent c63f098fb0
commit 52fbb14770

View File

@ -10,7 +10,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v1.5-0-g8adca9b #### $$VERSION$$ v1.51-dev-24-gc63f098
######################################################################## ########################################################################
###### ######
@ -29,6 +29,10 @@ export 'LANGUAGE=C.UTF-8'
unset IFS unset IFS
# set -f # if you are paranoid use set -f to disable globbing # set -f # if you are paranoid use set -f to disable globbing
# kill interactive script if not finished in time, e.g. user away or error
MAXWAIT="1m"
{ sleep "${MAXWAIT}"; printf "Stopping Questionnaire after %s, you need to much time to finish ... BYE\n" "${MAXWAIT}"; kill $$; wait 2>/dev/null ;} &
# simple yes/no question, defaults to no # simple yes/no question, defaults to no
printf "Hi, hello there\nWould you like some tea (y/n)?\n" printf "Hi, hello there\nWould you like some tea (y/n)?\n"
read -r answer <"${INPUT}" read -r answer <"${INPUT}"