Perl coding error in msvc build system?

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Perl coding error in msvc build system?
Date: 2014-06-04 02:30:50
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

I'm not sure whether the following coding actually detects any errors:

open(P, "cl /? 2>&1 |") || die "cl command not found";

open(P, "nmake /? 2>&1 |")
|| croak
"Unable to determine Visual Studio version: The nmake command wasn't found.";

The problem is that because of the shell special characters, the command
is run through the shell, but the shell ignores the exit status of
anything but the last command in the pipe. And the perlopentut man page
says "In such a case, the "open" call will only indicate failure if Perl
can't even run the shell.". I can confirm that on a *nix system. It
might be different on Windows, but it doesn't seem so.

The whole thing could probably be written in a less complicated way
using backticks, like

--- a/src/tools/msvc/
+++ b/src/tools/msvc/
@@ -72,16 +72,13 @@ sub DeterminePlatform

# Examine CL help output to determine if we are in 32 or 64-bit mode.
$self->{platform} = 'Win32';
- open(P, "cl /? 2>&1 |") || die "cl command not found";
- while (<P>)
+ my $output = `cl /? 2>&1`;
+ $? >> 8 == 0 or die "cl command not found";
+ if ($output =~ /^\/favor:<.+AMD64/)
- if (/^\/favor:<.+AMD64/)
- {
- $self->{platform} = 'x64';
- last;
- }
+ $self->{platform} = 'x64';
+ last;
- close(P);
print "Detected hardware platform: $self->{platform}\n";


Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2014-06-04 03:28:34 Re: pg_stat directory and pg_stat_statements
Previous Message Robert Haas 2014-06-04 02:28:19 Re: idle_in_transaction_timeout