Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14511

Re: exec/read -s bug?

From Lars Schneider <larsxschneider@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: exec/read -s bug?
Date 2018-08-19 21:12 +0200
Message-ID <mailman.5300.1534705937.1292.bug-bash@gnu.org> (permalink)
References <70D019FA-3393-404C-B689-20E499BC66B9@gmail.com> <2E73F4FF-7FCA-4648-8A30-0E3DC9320781@gmail.com>

Show all headers | View raw


> 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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: exec/read -s bug? Lars Schneider <larsxschneider@gmail.com> - 2018-08-19 21:12 +0200

csiph-web