X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=lib%2FUtils.pm;h=446d2e7589d31b00cf1df118700a8e33ec8d5efa;hb=f3e0cdceb40c69dc13b1edf6d9d2af3bd38798c1;hp=78af1712658f5e5ef9a49634407f424f89337ff1;hpb=a5e947bf363fa107c5f7de50e6334ddcec415eb0;p=clearscm.git diff --git a/lib/Utils.pm b/lib/Utils.pm index 78af171..446d2e7 100644 --- a/lib/Utils.pm +++ b/lib/Utils.pm @@ -156,7 +156,7 @@ Returns: or error "Can't write to $errorlog ($!)", 1; # Change the current directory to / - my $ROOT = $ARCH eq "windows" ? "C:\\" : "/"; + my $ROOT = $ARCHITECTURE eq "windows" ? "C:\\" : "/"; chdir $ROOT or error "Can't chdir to $ROOT ($!), 1"; @@ -232,17 +232,11 @@ STDOUT then do so in the $command passed in. =cut - # Save $SIG{CHLD} so we can set it to 'DEFAULT' and then restore it later. - # Helps when you are doing process handling. - my $sigchld = $SIG{CHLD}; - local $SIG{CHLD} = 'DEFAULT'; my @output = `$cmd`; my $status = $?; - local $SIG{CHLD} = $sigchld; - chomp @output; return ($status, @output); @@ -347,10 +341,9 @@ Returns: =cut - $prompt ||= 'Password'; - my $password; + my $password = ''; local $| = 1; @@ -371,9 +364,18 @@ Returns: last; } # if - print '*'; + # Handle backspaces + if ($key eq chr(127)) { + unless ($password eq '') { + chop $password; - $password .= $key; + print "\b \b"; + } # unless + } else { + print '*'; + + $password .= $key; + } # if } # while ReadMode 'restore'; # Reset tty mode before exiting. @@ -469,7 +471,7 @@ In a scalar context just the 1 minute load average. # TODO: Make it work on Windows... return if $^O =~ /win/i; - open my $loadAvg, '/proc/loadavg' + open my $loadAvg, '<', '/proc/loadavg' or croak "Unable to open /proc/loadavg\n"; my $load = <$loadAvg>;