Re: What about Perl autodie?

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, John Naylor <johncnaylorls(at)gmail(dot)com>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Subject: Re: What about Perl autodie?
Date: 2024-03-18 13:35:38
Message-ID: ACFA6733-68B8-447F-8A4F-6B77A0BA9F30@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 18 Mar 2024, at 14:18, Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org> wrote:
> Daniel Gustafsson <daniel(at)yesql(dot)se> writes:

>> It would have been nice to standardize on
>> using one of "|| die" and "or die" consistently but that's clearly not for this
>> body of work.
>
> "or die" is generally the preferred form, since || has higher precedence
> than comma, so it's easy to make mistakes if you don't parenthesise the
> function args, like:
>
> open my $fh, '>', $filname || die "can't open $filename: $!";
>
> which will only fail if $filename is falsy (i.e. undef, "", or "0").

Thanks for the clarification! Looking over the || die() codepaths we have, and
we'll add as part of this patchset, none are vulnerable to the above issue
AFAICT.

--
Daniel Gustafsson

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Étienne BERSAC 2024-03-18 13:37:13 Re: REVOKE FROM warning on grantor
Previous Message Jacob Champion 2024-03-18 13:34:16 Re: sslinfo extension - add notbefore and notafter timestamps