Skip to content

Commit

Permalink
Backport read_password improvement from master.
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed Feb 26, 2010
1 parent 1550440 commit c8fea29
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
27 changes: 21 additions & 6 deletions inst/lib/Bric/Inst.pm
Expand Up @@ -41,13 +41,28 @@ use strict;
use File::Spec::Functions qw(catdir tmpdir catfile);
eval { require Term::ReadPassword; import Term::ReadPassword 'read_password' };
if ($@) {
print "#" x 79, "\n\n", <<END, "\n", "#" x 79, "\n";
Bricolage installation requires Term::ReadPassword. Please install
this Perl module from CPAN.
END

exit 1;
# Poor man's Term::ReadPassword.
eval q{
use POSIX qw(:termios_h);
sub read_password {
print @_;
my $fd_stdin = fileno(STDIN);
my $term = POSIX::Termios->new;
$term->getattr($fd_stdin);
my $oflags = $term->getlflag;
my $no_echo = $oflags & ~(ISIG | ECHO | ICANON);
$term->setlflag($no_echo);
$term->setattr($fd_stdin, TCSAFLUSH);
my $answer = <STDIN>;
$term->setlflag($oflags);
$term->setattr($fd_stdin, TCSAFLUSH);
chomp $answer;
print $/;
return $answer;
}
};
}

require Exporter;
use base 'Exporter';
our @EXPORT_OK = qw(soft_fail hard_fail ask_yesno ask_confirm ask_choice
Expand Down
6 changes: 6 additions & 0 deletions lib/Bric/Changes.pod
Expand Up @@ -22,6 +22,12 @@ When displaying categories associated with a story when the
C<ENABLE_CATEGORY_BROWSER> F<bricolage.conf> directive is true, the categories
are now displayed in alphabetical order by URI. [David]

=item *

The installer no longer requires that L<Term::ReadPassword> be installed from
the CPAN before it continues. It will use it if it finds it, but if not
substitutes a simple implementation that does the trick (Bug #136). [David]

=back

=head2 Bug Fixes
Expand Down

0 comments on commit c8fea29

Please sign in to comment.