"Press any key to continue" function ... Problem when <Enter> is pressed ...
"Press any key to continue" function ... Problem when <Enter> is pressed ...
(OP)
Hi everyone,
I included the following function into my latest script:
So far so good and everything works fine except when you press the <Enter> key it will act like Q has been pressed and quit the script ...
Any ideas why that's so and what I can do about it ?
Best Regards,
Thomas
I included the following function into my latest script:
CODE
function fkt_continue { echo "\033[1;36mPress any key to continue (or <Q> to quit) ...\033[m" stty -echo stty raw key=$(dd bs=1 count=1 2> /dev/null) > /dev/null stty echo stty -raw if [ $key = "Q" -o "q" ]; then exit 1 fi }
So far so good and everything works fine except when you press the <Enter> key it will act like Q has been pressed and quit the script ...

Any ideas why that's so and what I can do about it ?
Best Regards,
Thomas
RE: "Press any key to continue" function ... Problem when <Enter> is pressed ...
Irrelevant what you press, that will always evaluate to true :
CODE --> command line
Maybe you want this instead :
CODE --> shell ( fragment )
Feherke.
feherke.ga
RE: "Press any key to continue" function ... Problem when <Enter> is pressed ...
Thanks a lot !