Perl coding error in msvc build system?

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Perl coding error in msvc build system?
Дата
Msg-id 1401849050.17288.0.camel@vanquo.pezone.net
обсуждение исходный текст
Ответы Re: Perl coding error in msvc build system?
Список pgsql-hackers
I'm not sure whether the following coding actually detects any errors:

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

VSObjectFactory.pm:
   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/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -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";}






В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: idle_in_transaction_timeout
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: pg_stat directory and pg_stat_statements