Re: perlcritic script

From: "Tels" <nospam-pg-abuse(at)bloodgate(dot)com>
To: "Peter Eisentraut" <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Andrew Dunstan" <andrew(dot)dunstan(at)2ndquadrant(dot)com>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: perlcritic script
Date: 2018-05-08 21:25:07
Message-ID: f834786ef274220e64b372989f1e3160.squirrel@sm.webmail.pair.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Moin,

On Tue, May 8, 2018 5:03 pm, Peter Eisentraut wrote:
> On 5/8/18 16:51, Tom Lane wrote:
>> Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
>>> On 5/8/18 13:57, Andrew Dunstan wrote:
>>>> + # take executable files that file(1) thinks are perl files
>>>> + find . -type f -perm -100 -exec file {} \; -print |
>>>> + egrep -i ':.*perl[0-9]*\>' |
>>
>>> How portable is that?
>>
>> Well, it's the same code that's in pgperltidy ... but I agree that
>> it's making a lot of assumptions about the behavior of file(1).
>
> OK, but then it's not a problem for this thread.

If I'm not mistaken, the first line in the "find" code could be more
compact like so:

find . -type f -iname '*.p[lm]'

(-print is default, and the -name argument is a regexp, anyway. And IMHO
it could be "-iname" so we catch "test.PM", too?).

Also, "-print" does not handle filenames with newlines well, so "-print0"
should be used, however, this can be tricky when the next step isn't xarg,
but sort. Looking at the man page, on my system this would be:

find . -type f -name '*.p[lm]' -print0 | sort -u -z | xargs -0 ...

Not sure if that is more, or less, portable then the original -print
variant, tho.

Best regards,

Tels

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-05-08 22:05:46 Re: [HACKERS] path toward faster partition pruning
Previous Message Thomas Munro 2018-05-08 21:05:59 Re: [HACKERS] Parallel Append implementation