Since darwin_866 has told us neither what OS is being used nor which version of bash is being used, we don't have any way to know if what you suggested might work in his/her environment. The following read then reads the next available character no matter when it was typed. The loop you suggest above silently throws away the diagnostic saying there is no -N option and gives no indication that whatever was intended to be done by the while loop didn't do anything. That might work with some versions of bash, but it won't work with 3.2.57 (which comes with the most recent release of macOS Mojave) since the read built-in in that version doesn't have a -N option. While read -rs -N 1 -t 0.1 2> /dev/null do : done Press 1 if you liked it, 2 if you didn't." So your script would look like this: #!/bin/bashĮcho "Ok now you can respond. Since you specify using bash shell we can flush the input buffer using: while read -rs -N 1 -t 0.1 2> /dev/null do : done
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |