zsh-users
 help / color / mirror / code / Atom feed
* Re: hiding input text
@ 1997-09-11  7:37 Swen Thuemmler
  0 siblings, 0 replies; 2+ messages in thread
From: Swen Thuemmler @ 1997-09-11  7:37 UTC (permalink / raw)
  To: zsh-users


What's wrong with stty -echo? Ok, it is not portable (works only on Unix),
perhaps someone has a portable solution... Here is a quick and dirty
getpass function. It should perhaps have a trap to restore the terminal
modes on exit. And I found no other way to get a newline in a string than
to use single quotes (I tried \n and echo but did not succeed).

Hope this helps

--Swen


#!/usr/bin/zsh

function getpass() {
  echo -n "Password: "
  stty -echo
  key=""
  end='
'
  while ( true ); do
    read -k key
    if [[ "$key" == "$end" ]]; then
      break
    fi
    echo -n .
    pass="$pass$key"
  done
  echo
  stty echo
}

getpass
echo "Password was $pass"



^ permalink raw reply	[flat|nested] 2+ messages in thread

* hiding input text
@ 1997-09-10 19:36 Jason Zapman II
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Zapman II @ 1997-09-10 19:36 UTC (permalink / raw)
  To: zsh-users

I'm attempting to write some front end scripts for some programs that
require passwords.

I would like to query the user for these passwords, but not have what they
type be displayed.

Can zsh do this, and if so, how?

(And if not, it would probably be a VERY useful thing to impliment)

Jason

-- 
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\  Jason Zapman II   \\ My pid is Inigo Montoya.  You kill -9 my parent  /
/  CS major, Listener, \\ process.  Prepare to vi. (seen on r.a.sf.w.r-j)\
\  And Partaker of       \\ "As a dog returns to his vomit, so a fool    /
/  MushMouthic Thoughts.   \\ returns to his folly."  Proverbs 26:11     \
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-09-11  7:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-11  7:37 hiding input text Swen Thuemmler
  -- strict thread matches above, loose matches on Subject: below --
1997-09-10 19:36 Jason Zapman II

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).