On Wed, Nov 27, 2002 at 05:01:05PM -0800, Mike Castle wrote:
> Many of these use ::prompt.  Sometimes I do NOT want the defaults, but give
> it an answer.
> 
> However, something like:
> 
> #!/bin/sh
> perl Makefile.PL << \EOF
> one
> two
> three
> EOF
> 
> does NOT work, because of the tty checks.

<snip>

> So, would something like:
> 
> -    if ($ISA_TTY && !$ENV{PERL_MM_USE_DEFAULT}) {
> +    if (($ISA_TTY && !$ENV{PERL_MM_USE_DEFAULT}) || $ENV{PERL_MM_USE_STDIN}) {
> 
> be acceptable?

I understand your problem, but the proposed solution is kinda clumsy.  Would
be better if it just DWIMed.

If STDIN is not open to a TTY, would this work without a risk of causing
prompt() to block indefinately: Either we're on a TTY or there's something
on STDIN or PERL_MM_USE_DEFAULT is set.

--- lib/ExtUtils/MakeMaker.pm   26 Nov 2002 03:39:27 -0000      1.80
+++ lib/ExtUtils/MakeMaker.pm   28 Nov 2002 19:37:42 -0000
@@ -133,7 +133,7 @@
     local $|=1;
     local $\;
     print "$mess $dispdef";
-    if ($ISA_TTY && !$ENV{PERL_MM_USE_DEFAULT}) {
+    if ($ISA_TTY || !eof STDIN || $ENV{PERL_MM_USE_DEFAULT}) {
         $ans = <STDIN>;
         if( defined $ans ) {
             chomp $ans;
@@ -2289,10 +2292,10 @@
 input.  If a $default is provided it will be used as a default.  The
 function returns the $value selected by the user.
 
-If C<prompt()> detects that it is not running interactively, 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 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.
 


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
11. Every old idea will be proposed again with a different name and
    a different presentation, regardless of whether it works.
     -- RFC 1925

Reply via email to