# from Andreas J. Koenig
# on Sunday 04 March 2007 12:25 pm:
> > Ok, pretend I said "> /tmp/foo" or "| thbbt" in the example. In
> all > three cases, it should not be prompting without a non-terminal
> STDIN.
>
>I'm sorry, I cannot agree. If people deliberately keep their STDIN on
>the terminal, then the terminal should be treated as the legitimate
>owner of the input stream. That is exactly the situation for which I
>filed this bug.
You're saying you want the prompt to be printed when STDOUT is not a
terminal (possibly even /dev/null) and you're prepared to answer
*interactively* on STDIN at the terminal? What's the use-case for this?
Some sort of half-harness? Looking at your original post, I would not
be expecting you to want a prompt.
Digging up some history, I see that EU::MM does print the prompt and
wait for an answer, but is that really the intended behavior or just a
side-effect of the way scripted STDIN was implemented? The 6.06_01
Changes file simply says "prompt() will now read from STDIN.", but
doesn't say whether it intended to redefine the defaulting behavior
from "default" to "wait forever".
perl -e 'use lib "6.05/lib";
use ExtUtils::MakeMaker;
warn ExtUtils::MakeMaker::prompt("foo", "bar"); ' > /tmp/prompt
This simply took the default because STDOUT was not on the terminal. As
of 6.06_01, it waits for input, but does that make it correct? (Or at
least: is that they way all of the cool kids are using it these days?)
My take is that we have these four use-cases:
o leave me alone: PERL_MM_USE_DEFAULT
o ask me questions: -t STDIN and -t STDOUT
o I can't hear you: -t STDIN and not -t STDOUT
o harness/scripted: not -t STDIN and not -t STDOUT
Does that cover it? If people *really* want this half-harness behavior,
let's find SOMETHING that doesn't make "I can't hear you" behave so
wrongly (at least put the prompt on both STDERR and STDOUT, though I
would call that far from optimal.)
Regardless, the r9182 'fileno' change redefines the behavior WRT passing
a missing default to prompt(). I think "we're out of answers" should
be the same as when PERL_MM_USE_DEFAULT is set.
$ svn up -r 9182 lib/Module/Build/Base.pm
U lib/Module/Build/Base.pm
Updated to revision 9182.
$ echo "foo" | perl -e 'use Module::Build;
warn Module::Build->prompt("foo", "bar");
warn Module::Build->prompt("this");'
foo [bar] foo at -e line 1, <STDIN> line 1.
this
Warning: something's wrong at -e line 1, <STDIN> line 1.
$ PERL_MM_USE_DEFAULT=1 perl -e 'use Module::Build;
warn Module::Build->prompt("foo", "bar");
warn Module::Build->prompt("this");'
foo [bar] bar
bar at -e line 1.
ERROR: This build seems to be unattended, but there is no default
value for this question. Aborting.
$ svn up -r 9181 lib/Module/Build/Base.pm
U lib/Module/Build/Base.pm
Updated to revision 9181.
$ echo "foo" | perl -e 'use Module::Build;
warn Module::Build->prompt("foo", "bar");
warn Module::Build->prompt("this");'
foo [bar] foo at -e line 1, <STDIN> line 1.
ERROR: This build seems to be unattended, but there is no default
value for this question. Aborting.
$ svn up lib/Module/Build/Base.pm
U lib/Module/Build/Base.pm
Updated to revision 9211.
$ echo "foo" | perl -e 'use Module::Build;
warn Module::Build->prompt("foo", "bar");
warn Module::Build->prompt("this");'
foo [bar] foo at -e line 1, <STDIN> line 1.
ERROR: This build seems to be unattended, but there is no default
value for this question. Aborting.
In any case, we need to print the prompt and *then* check STDIN or
otherwise rearrange the manner in which we try to determine whether (@_
== 1) is an error.
--Eric
--
Turns out the optimal technique is to put it in reverse and gun it.
--Steven Squyres (on challenges in interplanetary robot navigation)
---------------------------------------------------
http://scratchcomputing.com
---------------------------------------------------