read a single pushed key by a dash script

Oliver Grawert ogra at ubuntu.com
Sun Nov 6 15:59:46 UTC 2016


hi,
On So, 2016-11-06 at 16:54 +0100, Oliver Grawert wrote:
> hi,
> 
> On So, 2016-11-06 at 14:25 +0100, Ralf Mardorf wrote:
> 
> > 
> > does anybody know a more neat solution, than using bash's read in a
> > dash script?
> > 
> >   bash -c "read -n1 answer"
> 
> you could try:
> 
> stty raw; REPLY=$(dd bs=1 count=1 2> /dev/null); stty -raw
> 

hmm, even though ... -raw can be evil if you want to be able to ctrl-C
out of your script ...

stty -icanon -echo
REPLY=$(dd bs=1 count=1 2> /dev/null)
stty icanon echo

might be cleverer ...

ciao
	oli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20161106/b9c81fd5/attachment.sig>


More information about the ubuntu-users mailing list