#651446 dash builtin read has no -s option for silent

Package:
dash
Source:
dash
Description:
POSIX-compliant shell
Submitter:
Glenn Haecker
Date:
2011-12-18 21:39:09 UTC
Severity:
wishlist
#651446#5
Date:
2011-12-08 17:12:04 UTC
From:
To:
Dear Maintainer,

POSIX compliant or not, it would be nice to have an -s (silent) option fro the
builtin read command.  It's quite useful for inputing a password.

Thanks for considering it.

#651446#10
Date:
2011-12-08 17:27:26 UTC
From:
To:
tags 651446 + upstream wontfix
quit

Hi,

Glenn Haecker wrote:

Thanks, sounds useful indeed.

dash is meant to be as small and fast as possible given the functionality
it aims to provide (POSIX and some backward compatibility features).  So
while you are free to submit this change to dash@vger.kernel.org and it
may even be accepted if it is made optional at compile time, a simpler
approach would be to add it to POSIX.

Unfortunately, the "-s" option is already in use for a different
purpose in ksh93 (Debian package "ksh"):

	If the -s option is present, the input will be saved as a
	command in the history file.

If you want this functionality in POSIX, it would presumably have to
use a different letter.  See http://www.austingroupbugs.net/ and
http://www.opengroup.org/austin/ if interested in working on that.

Sincerely,
Jonathan

#651446#17
Date:
2011-12-18 21:25:31 UTC
From:
To:
You can turn off echoing using a sequence like

settings=$(stty -g)
stty -echo
IFS= read -r password
stty "$settings"

Some additional code is required to restore the terminal settings even
if SIGINT, SIGQUIT, SIGTERM or similar happens.