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


Groups > gnu.bash.bug > #14511 > unrolled thread

Re: exec/read -s bug?

Started byLars Schneider <larsxschneider@gmail.com>
First post2018-08-19 21:12 +0200
Last post2018-08-19 21:12 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#14511 — Re: exec/read -s bug?

FromLars Schneider <larsxschneider@gmail.com>
Date2018-08-19 21:12 +0200
SubjectRe: exec/read -s bug?
Message-ID<mailman.5300.1534705937.1292.bug-bash@gnu.org>
> 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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web