WIP: Added timeout on read function #6

Draft
Ghost wants to merge 3 commits from timeout-read into master
Showing only changes of commit 269336fcf0 - Show all commits

View file

@ -65,13 +65,14 @@ get_now() {
# timeout on read(), uses TMOUT env as timer
timedout_read() {
if [ -z ${TMOUT+x} ] || [ "$TMOUT" = 0 ]; then
export TMOUT=36000
if [ -z "${TMOUT+x}" ] || [ "$TMOUT" = 0 ]; then
# maximum allowed by stty
export TMOUT=25
fi
user_input=$1
old_tty_settings=$(stty -g)
stty -icanon min 0 time ${TMOUT}0
Review

10:2: note: read without -r will mangle backslashes. [SC2162]

10:7: note: Double quote to prevent globbing and word splitting. [SC2086]

10:2: note: read without -r will mangle backslashes. [SC2162] 10:7: note: Double quote to prevent globbing and word splitting. [SC2086]
Review

Strange that it didn't erase the review automatically.

Strange that it didn't erase the review automatically.
read $user_input
read -r "$user_input"
stty "$old_tty_settings"
unset TMOUT
}