From a0afcac06485b33b487e5c573d30df98b229a3ce Mon Sep 17 00:00:00 2001 From: Andrew DeFaria Date: Fri, 16 Oct 2020 09:36:23 -0700 Subject: [PATCH] Changed to properly handle backspace when entering passwords --- lib/Utils.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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. -- 2.17.1