From 610cce2385d9ff49ee08dae05975dfa66e72aec9 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Fri, 3 Aug 2012 20:01:31 -0400 Subject: [PATCH] Ensure STATUS_FILE always a valid filehandle. There was a bug with printing to STATUS_FILE that wasn't guarded by checking to see if $outfile was defined, which was causing errors when printing that a module failed to update/build in --pretend mode. I could have fixed it by adding that check but it's probably better to have it always valid. We can't set $outfile to '/dev/null' unconditionally since we decide whether to create log/latest symlinks based on whether $outfile is set or not. So instead I use a defined-or (//) operator in the open call. --- kdesrc-build | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/kdesrc-build b/kdesrc-build index e8b9403..c137c77 100755 --- a/kdesrc-build +++ b/kdesrc-build @@ -7945,19 +7945,16 @@ sub handle_build # build. $ipc->waitForStreamStart(); - my $outfile = undef; + my $outfile = pretending() ? undef + : $ctx->getLogDir() . '/build-status'; - if (not pretending()) - { - $outfile = $ctx->getLogDir() . '/build-status'; - open STATUS_FILE, ">$outfile" or do { - error (<', $outfile // '/dev/null') or do { + error (<build()) { my $elapsed = prettify_seconds(time - $start_time); - print STATUS_FILE "$module: Succeeded after $elapsed.\n" if $outfile; + print STATUS_FILE "$module: Succeeded after $elapsed.\n"; $module->setPersistentOption('last-build-rev', $module->currentScmRevision()); $module->setPersistentOption('failure-count', 0); @@ -8038,7 +8035,7 @@ EOF else { my $elapsed = prettify_seconds(time - $start_time); - print STATUS_FILE "$module: Failed after $elapsed.\n" if $outfile; + print STATUS_FILE "$module: Failed after $elapsed.\n"; info ("\tOverall time for r[$module] was g[$elapsed]."); $ctx->markModulePhaseFailed('build', $module);