>>>>> On Sun, 4 Mar 2007 15:47:09 -0800, Eric Wilhelm <[EMAIL PROTECTED]> said:
> # 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? Yes. > What's the use-case for this? Capture output. > Some sort of half-harness? Looking at your original post, I would not > be expecting you to want a prompt. Yes, sorry, the beginning of this bugreport was very vague because it was cumbersome for me. This was because I did not find out what was going on at all. If a terminal hangs for no apparent reason, does not hang in the debugger, does not hang in interactive mode but hangs as soon as STDOUT is redirected, you can have a hard time writing a bug report. > 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? I cannot speak for MM but I'd call it sane behaviour. > 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?) I'm just a bear of small brain but I would expect that he who asks a question listens to my answer. And that he trusts that I am able to handle the device that we are using to communicate. > 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 Very nice summary. I'd label the third one with "capture" though. > 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.) Writing to both STDOUT and STDERR is unacceptable. Asking a question twice and expecting only one answer will hardly lead to a balance between questions and answers. > 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. Don't know. > $ 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. I'm pretty sure that you can get the behaviour you want without using eof() at all, just with defined(): % echo "foo\nbar"|perl -le 'print defined <> ? "defined" : "undef" for 0..3' defined defined undef undef -- andreas