Skip to content

Commit

Permalink
Mod config script to tee output to config.log
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlum committed Jan 5, 2011
1 parent 07c6d61 commit 984cb27
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Configure.pl
Expand Up @@ -23,6 +23,44 @@

$| = 1; # $OUTPUT_AUTOFLUSH = 1;

sub tee {
# Try forking.
my $pid = open(STDOUT, "|-");
die "cannot fork: $!" unless defined $pid;

if ($pid) {
# Parent redirects stderr to stdout and returns.
open(STDERR, ">&STDOUT");
}
else {
# Child opens the log file and then exits when the parent does.
die "cannot open config.log for writing: $!" unless open(my $handle, ">", "config.log");

select($handle);
$| = 1;

while(sysread(*STDIN, $_, 2048) > 0) {
# Log prompt responses to file as well.
if(/^<promptanswer (.*)>\n(.*)$/) {
print "$1\n";

# If we slurped some extra data, print that normally.
if($2) {
print $2;
print STDOUT $2;
}

next;
}

print $_;
print STDOUT $_;
}
exit;
}
}
tee();

# Install Option text was taken from:
#
# autoconf (GNU Autoconf) 2.59
Expand Down
2 changes: 2 additions & 0 deletions lib/Parrot/Configure/Utils.pm
Expand Up @@ -161,6 +161,8 @@ sub prompt {
$value = $input;
}

print("<promptanswer $input>\n");

return integrate( $value, $input );
}

Expand Down

0 comments on commit 984cb27

Please sign in to comment.