From: Andrew DeFaria Date: Fri, 16 Oct 2020 16:36:23 +0000 (-0700) Subject: Changed to properly handle backspace when entering passwords X-Git-Url: https://defaria.com/gitweb/?a=commitdiff_plain;ds=inline;h=a0afcac06485b33b487e5c573d30df98b229a3ce;p=clearscm.git Changed to properly handle backspace when entering passwords --- diff --git a/lib/Utils.pm b/lib/Utils.pm index 8aabcaa..29e020c 100644 --- a/lib/Utils.pm +++ b/lib/Utils.pm @@ -341,10 +341,9 @@ Returns: =cut - $prompt ||= 'Password'; - my $password; + my $password = ''; local $| = 1; @@ -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.