Subject: Re: [PATCH] global: resolve Perl executable via PATH

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Thu, 06 Apr 2023 10:05:46 +0200

On Wed, Apr 05 2023, Eric Wong wrote:

> Patrick Steinhardt <[email-masked]> wrote:
>> diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
>> index 755a110bc4..3fe43b8968 100755
>> --- a/Documentation/cmd-list.perl
>> +++ b/Documentation/cmd-list.perl
>> @@ -1,5 +1,6 @@
>> -#!/usr/bin/perl -w
>> +#!/usr/bin/env perl
>>  
>> +use warnings;
>
> Fwiw, adding `use warnings' only affects the current scope
> (package main), whereas `-w' affects the entire Perl process.
>
> I prefer `-w' since adding `use warnings' everywhere is
> annoyingly verbose and I only use 3rd-party code that's
> warning-clean.

I much prefer "use warnings", and it's what we should be using. Note
that "-w" isn't just "global warnings", but for anything non-trivial
you'll likely be tripped up by "-w" being dynamically scoped, and "use
warnings" being lexically scoped. See "What's wrong with -w and $^W" in
"perldoc warnings".

In any case, I think it's fine to change these to "use warnings", and
the behavior won't change, as the scripts are trivial, and the either
don't use any modules, or use perl core modules that are (presumably)
warning-free.

But I think that change really should be split up from any proposed
shebang change, as it's just being made here because by usin g"env" in
particular we can't pass the "-w" argument...