This works but there are two caveats you should bear in mind:
If you're running the script as a priviledged process you might have just opened yourself to a local attack, if the user can modify their path and slip in a trojan 'stty' binary.
This fails utterly on Windows, amongst other systems.