Re: [Module::Build] PERL_MM_USE_DEFAULT
Status: Beta
Brought to you by:
kwilliams
|
From: Yitzchak Scott-T. <sth...@ef...> - 2006-01-19 20:59:36
|
Oops, right. I would be inclined to make y_n require a default.
Without it, the build is going fail for the first person who
runs with </dev/null (in the existing code) or PERL_MM_USE_DEFAULT=1
(with my patch to prompt()).
Might as well force the module author to not make this mistake.
--- lib/Module/Build/Base.pm.orig 2006-01-18 22:13:09.393200000 -0800
+++ lib/Module/Build/Base.pm 2006-01-19 12:05:44.234734400 -0800
@@ -379,6 +379,7 @@
sub y_n {
my $self = shift;
die "y_n() called without a prompt message" unless @_;
+ die "y_n() called without y or n default" unless ($_[1]||"")=~/[yn]/i;
my $interactive = $self->_is_interactive;
my $answer;
@@ -386,7 +387,6 @@
$answer = $self->prompt(@_);
return 1 if $answer =~ /^y/i;
return 0 if $answer =~ /^n/i;
- die "No y/n answer given, no default supplied, and no user to ask again" unless $interactive;
print "Please answer 'y' or 'n'.\n";
}
}
On Thu, Jan 19, 2006 at 09:58:52AM -0800, Tyler MacDonald wrote:
> Yitzchak Scott-Thoennes <sth...@ef...> wrote:
> > I think _is_interactive should stay the same in how it is used in y_n,
> > but prompt() should be made to work like EU::MM::prompt. This means
> > skipping the read if PERL_MM_USE_DEFAULT is set, but actually trying
> > to read even if not interactive, so an input file of responses can be
> > given. This should do it:
>
> I agree this makes more sense, but there's one problem. With your
> change, it looks like if:
>
> - PERL_MM_USE_DEFAULT is set,
> - and y_n() is called without a default,
> - *and* the session is attached to at terminal
>
> then y_n will just loop forever. :-/
|