Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plFMD-0002br-Rk for pgsql-committers@arkaria.postgresql.org; Sat, 08 Apr 2023 20:40:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1plFMC-0006Ly-HJ for pgsql-committers@arkaria.postgresql.org; Sat, 08 Apr 2023 20:40:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plFMC-0006Lp-AB for pgsql-committers@lists.postgresql.org; Sat, 08 Apr 2023 20:40:20 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1plFM9-001hbx-9K for pgsql-committers@lists.postgresql.org; Sat, 08 Apr 2023 20:40:19 +0000 Received: (Authenticated sender: adsend@dunslane.net) by mail.gandi.net (Postfix) with ESMTPSA id 0DA8620003; Sat, 8 Apr 2023 20:40:13 +0000 (UTC) Content-Type: multipart/alternative; boundary="------------zQeeyXc5xmPEA62QSslScz8S" Message-ID: Date: Sat, 8 Apr 2023 16:40:12 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: pgsql: Skip \password TAP test on old IPC::Run versions Content-Language: en-US To: Tom Lane , Daniel Gustafsson Cc: pgsql-committers@lists.postgresql.org References: <6d880ea2-f8ca-f458-4dcd-a7a3e6d6cd7c@dunslane.net> <3588535.1680971029@sss.pgh.pa.us> <627E6024-7803-473C-91AF-E8D76C3D99E0@yesql.se> <3618405.1680985800@sss.pgh.pa.us> From: Andrew Dunstan In-Reply-To: <3618405.1680985800@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------zQeeyXc5xmPEA62QSslScz8S Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2023-04-08 Sa 16:30, Tom Lane wrote: > Daniel Gustafsson writes: >> On 8 Apr 2023, at 18:23, Tom Lane wrote: >>> Can't we write "use IPC::Run 0.98;" and let >>> some other code manage the version comparison? >> We can, but that AFAIK (Andrew might have a better answer) requires the below >> diff which I think leaves some readability to be desired: >> - (eval { require IO::Pty; } && eval { $IPC::Run::VERSION >= '0.98' }); >> + (eval { require IO::Pty; } && !!eval { IPC::Run->VERSION('0.98'); 1 }); > Maybe I'm missing something, but I was envisioning > > eval { require IO::Pty; use IPC::Run 0.98; } > > with no need to do more than check if the eval traps an error. > > You need to be careful with "use". It is executed in the compile phase, so I'd avoid it here. cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------zQeeyXc5xmPEA62QSslScz8S Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit


On 2023-04-08 Sa 16:30, Tom Lane wrote:
Daniel Gustafsson <daniel@yesql.se> writes:
On 8 Apr 2023, at 18:23, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Can't we write "use IPC::Run 0.98;" and let
some other code manage the version comparison?

      
We can, but that AFAIK (Andrew might have a better answer) requires the below
diff which I think leaves some readability to be desired:

      
-   (eval { require IO::Pty; } && eval { $IPC::Run::VERSION >= '0.98' });
+   (eval { require IO::Pty; } && !!eval { IPC::Run->VERSION('0.98'); 1 });
Maybe I'm missing something, but I was envisioning

	eval { require IO::Pty; use IPC::Run 0.98; }

with no need to do more than check if the eval traps an error.

			

You need to be careful with "use". It is executed in the compile phase, so I'd avoid it here.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------zQeeyXc5xmPEA62QSslScz8S--