On Feb 5, 2007, at 12:53 AM, Eric Wilhelm wrote:

From my experiment, this doesn't change the behavior. It just causes it
to hang later in _readline() instead.

In my experiment it seems to work. I set things up with the scenario Andreas described (STDOUT is redirected to a file, STDIN is live). blib/ has the new code, otherwise it's hitting M::B 0.2806:


---------------------------------------------------------
[scotchie:~/src/Module-Build-svk] ken% cat prompt.pl
use Module::Build;

my $unatt = Module::Build->_is_unattended;
warn "Unattended: $unatt\n";

my $ans = Module::Build->prompt("Answer?", "default");
print "You say $ans!\n";

[scotchie:~/src/Module-Build-svk] ken% perl -Mblib prompt.pl
Unattended:
Answer? [default] nondefault
You say nondefault!

[scotchie:~/src/Module-Build-svk] ken% perl prompt.pl
Unattended:
Answer? [default] nondefault
You say nondefault!

[scotchie:~/src/Module-Build-svk] ken% perl -Mblib prompt.pl > foo
Unattended: 1

[scotchie:~/src/Module-Build-svk] ken% cat foo
Answer? [default] default
You say default!

[scotchie:~/src/Module-Build-svk] ken% perl -Mblib prompt.pl | tee foo
Unattended:
Answer? [default] nondefault
You say nondefault!

[scotchie:~/src/Module-Build-svk] ken% cat foo
Answer? [default] You say nondefault!

[scotchie:~/src/Module-Build-svk] ken% perl prompt.pl > foo
^C (hangs)

---------------------------------------------------------

Note that when you 'tee' output you get to answer, but when you use '>' you don't. Which I think makes some kind of sense - with the former you get to see the question, with the latter you don't.

I think it's okay for it to "hang" in _readline(), because STDIN is live and we're asking the user a question - recall that his initial proposed fix was just to unbuffer STDOUT with $| = 1. What I think Andreas was saying is not okay is to hang while just trying to determine whether STDIN is live.

 -Ken

Reply via email to