X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=lib%2FUtils.pm;h=29e020cb843a340d502895c900d4be1258128fd3;hb=ded8d315fd3f6c050f759865b09f053ae85e52a5;hp=f52fe4be1acc442d817d541361c0d99767a5f9fd;hpb=201c4691639017573d7caf7bf03de6bf12db6614;p=clearscm.git diff --git a/lib/Utils.pm b/lib/Utils.pm index f52fe4b..29e020c 100644 --- a/lib/Utils.pm +++ b/lib/Utils.pm @@ -341,10 +341,9 @@ Returns: =cut - $prompt ||= 'Password'; - my $password; + my $password = ''; local $| = 1; @@ -357,7 +356,7 @@ Returns: while () { my $key; - while (not defined ($key = ReadKey -1)) { } + while (not defined ($key = ReadKey -1)) { } if ($key =~ /(\r|\n)/) { print "\n"; @@ -365,9 +364,18 @@ Returns: last; } # if - print '*'; + # Handle backspaces + if ($key eq chr(127)) { + unless ($password eq '') { + chop $password; + + print "\b \b"; + } # unless + } else { + print '*'; - $password .= $key; + $password .= $key; + } # if } # while ReadMode 'restore'; # Reset tty mode before exiting.