[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Supressing display of passwords



On Thu, 18 Nov 1999, Eric Albert <ejalbert@cs.stanford.edu> wrote:

>Alan Fry posted a script to do this through the Dialog Manager on 
>2/28/98.  I'll keep things short and not post it here, but it should 
>be in the archives.  If not, let me know....

It is indeed!  One is advised to search on the keyword 'hiding' instead 
of 'suppressing' or 'obscuring', though.  Thanks Eric (and Alan).


As an addendum to my original post, the following modification allows the 
code to handle delete/backspace as well - making it more intuitive and 
robust.

`stty raw`;
while (($char = getc()) ne "\n")
{
  if ($char eq "\b") { chop $pass; }
  elsif ($char =~ /\w/) { $pass .= $char; }
  else { sleep 1; }
}
`stty sane`;

\b is a backspace (delete on a Mac), so simply chopping off the last 
character of the password every time one's encountered makes sense.  Note 
that \b actually stands for a word boundary if used in the context of a 
regular expression, which is why eq "\b" is used instead of =~ /\b/.

Henry.

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org