Re: [Module::Build] PERL_MM_USE_DEFAULT
Status: Beta
Brought to you by:
kwilliams
|
From: Yitzchak Scott-T. <sth...@ef...> - 2006-01-19 11:14:36
|
On Wed, Jan 18, 2006 at 06:55:59PM -0800, Tyler MacDonald wrote:
> Ken,
>
> Would it be possible to change this:
>
> sub _is_interactive {
> return -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
> }
>
> To this:
>
> sub _is_interactive {
> return (!$ENV{PERL_MM_USE_DEFAULT}) && -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
> }
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:
--- Module-Build-0.27_05/lib/Module/Build/Base.pm.orig 2006-01-17 00:39:03.266454000 -0800
+++ Module-Build-0.27_05/lib/Module/Build/Base.pm 2006-01-18 22:13:09.393200000 -0800
@@ -358,7 +358,8 @@ sub prompt {
print "$mess $dispdef";
}
my $ans;
- if ($self->_is_interactive) {
+ if ( ! $ENV{PERL_MM_USE_DEFAULT} &&
+ ( $self->_is_interactive || ! eof STDIN ) ) {
$ans = <STDIN>;
if ( defined $ans ) {
chomp $ans;
--- Module-Build-0.27_05/lib/Module/Build/Authoring.pod.orig 2006-01-12 15:56:39.000000000 -0800
+++ Module-Build-0.27_05/lib/Module/Build/Authoring.pod 2006-01-18 22:16:49.970374400 -0800
@@ -1229,10 +1229,12 @@
which is optional, specifies a default answer (for example,
C<"wallet">). The user will be asked the question once.
-If the current session doesn't seem to be interactive (i.e. if
-C<STDIN> and C<STDOUT> look like they're attached to files or
-something, not terminals), we'll just use the default without
-letting the user provide an answer.
+If C<prompt()> detects that it is not running interactively and there
+is nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable
+is set to true, the $default will be used without prompting. This
+prevents automated processes from blocking on user input.
+
+If no $default is provided an empty string will be used instead.
This method may be called as a class or object method.
The doc paragraphs are taken verbatim from makemaker.
Hope this sounds ok,
Yitzchak (who's starting to wonder if Ken is on vacation)
|