Re: stty not restored in trap when executing read with options
On 7/16/17 6:59 PM, Quentin L'Hours wrote:
> bash: 4.4.12(1)-release
> stty: 8.25 (GNU version)
> When running this small script:
>> trap 'stty echo; exit 0' INT
>> stty -echo
>> read -d a
> and hitting Ctrl-c
> stty should be restored in the trap, but doesn't (the trap code is executed
> This also seems to happen with read -s and -n options.
This is pretty easy to explain. The read builtin takes great care to
restore the terminal settings it changes before the shell exits.
This was prompted by several bug reports over time, the last of which
(the one that finally resulted in the change) is: