[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exec/read -s bug?
From: |
Lars Schneider |
Subject: |
Re: exec/read -s bug? |
Date: |
Sun, 19 Aug 2018 21:12:07 +0200 |
> On Aug 19, 2018, at 8:45 PM, Lars Schneider <larsxschneider@gmail.com> wrote:
>
>
>> On Aug 19, 2018, at 6:33 PM, Lars Schneider <larsxschneider@gmail.com> wrote:
>>
>> Hi,
>>
>> consider this script:
>>
>> #!/bin/bash
>> [ "`whoami`" = "root" ] || {
>> exec sudo -u root "$0" "$@"
>> }
>> read -s -p "enter stuff: " stuff
>>
>> If I run the script as normal user (not root!) and I abort the "read -s -p"
>> call with "ctrl-c", then my shell is still in silent mode.
>>
>> I can consitently replicate that behavior on Ubuntu 14.04.5 LTS (Trusty)
>> and BASH 4.3.11(1)-release (x86_64-pc-linux-gnu) as well as BASH 4.3.30.
>>
>> I also installed BASH 4.4.18 from source and I can replicate the issue.
>
> I did a mistake: The problem _was_ fixed with BASH 4.4.18.
> Further testing revealed that it is fixed with 4.4. too but not in Bash-4.3
> patch 46.
>
> I think the following item in the release notes corresponds to the problem:
>
> oo. Fixed a bug that caused bash to not clean up readline's state, including
> the terminal settings, if it received a fatal signal while in a readline()
> call (including `read -e' and `read -s').
>
> Does anyone see a workaround to set the readline state properly
> for older BASH versions?
OK, I found a work around:
[ "`whoami`" = "root" ] || {
exec sudo -u root "$0" "$@"
}
function finish {
stty echo echok
}
trap finish EXIT
read -s -p "enter stuff: " stuff
echo "answer: $stuff"
Cheers,
Lars