Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

1
  • I know is not an answer to the question, but i had a similar issue, where I needed a values coming through STDIN stored in a variable, but read was halting my program and as mentioned if read times out if will empty the content of the variable, my solution was to use parameter expansion, what it does is, if it times out if assigns a "default" value to the variable... var=a while true do echo $var read -t 0.1 input input=${input:-$var} var=$input sleep 0.1 done as I said is not the right answer for you as you just wanted the key pressed and not the value entered... NOTE: whit this timings there Commented Jul 24, 2016 at 6:54