Until PG15, calling pgindent without arguments would process the whole tree. Now you get

No files to process at ./src/tools/pgindent/pgindent line 372.

Is that intentional?


Also, pgperltidy accepts no arguments and always processes the whole tree. It would be nice if there were a way to process individual files or directories, like pgindent can.

Attached is a patch for this.

(It seems that it works ok to pass regular files (not directories) to "find", but I'm not sure if it's portable.)
From ef9d9cc052d77e1509ce18dc004ac0ab96903a13 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 25 May 2023 11:02:25 +0200
Subject: [PATCH] Allow passing files on command line of pgperltidy

---
 src/tools/perlcheck/find_perl_files | 7 +++++--
 src/tools/perlcheck/pgperlcritic    | 2 +-
 src/tools/perlcheck/pgperlsyncheck  | 2 +-
 src/tools/pgindent/pgperltidy       | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/tools/perlcheck/find_perl_files 
b/src/tools/perlcheck/find_perl_files
index fd99dab83b..ad15f6b47a 100644
--- a/src/tools/perlcheck/find_perl_files
+++ b/src/tools/perlcheck/find_perl_files
@@ -3,11 +3,14 @@
 # shell function to find all perl files in the source tree
 
 find_perl_files () {
+       if [ $# -eq 0 ]; then
+               set -- .
+       fi
     {
                # take all .pl and .pm files
-               find . -type f -name '*.p[lm]' -print
+               find "$@" -type f -name '*.p[lm]' -print
                # take executable files that file(1) thinks are perl files
-               find . -type f -perm -100 -exec file {} \; -print |
+               find "$@" -type f -perm -100 -exec file {} \; -print |
                egrep -i ':.*perl[0-9]*\>' |
                cut -d: -f1
        } | sort -u | grep -v '^\./\.git/'
diff --git a/src/tools/perlcheck/pgperlcritic b/src/tools/perlcheck/pgperlcritic
index 1c2f787580..2ec6f20de3 100755
--- a/src/tools/perlcheck/pgperlcritic
+++ b/src/tools/perlcheck/pgperlcritic
@@ -14,7 +14,7 @@ PERLCRITIC=${PERLCRITIC:-perlcritic}
 
 . src/tools/perlcheck/find_perl_files
 
-find_perl_files | xargs $PERLCRITIC \
+find_perl_files "$@" | xargs $PERLCRITIC \
          --quiet \
          --program-extensions .pl \
          --profile=src/tools/perlcheck/perlcriticrc
diff --git a/src/tools/perlcheck/pgperlsyncheck 
b/src/tools/perlcheck/pgperlsyncheck
index 730f5927cd..da59c9727c 100755
--- a/src/tools/perlcheck/pgperlsyncheck
+++ b/src/tools/perlcheck/pgperlsyncheck
@@ -13,4 +13,4 @@ set -e
 # for zsh
 setopt shwordsplit 2>/dev/null || true
 
-find_perl_files | xargs -L 1 perl $INCLUDES -cw 2>&1 | grep -v OK
+find_perl_files "$@" | xargs -L 1 perl $INCLUDES -cw 2>&1 | grep -v OK
diff --git a/src/tools/pgindent/pgperltidy b/src/tools/pgindent/pgperltidy
index 5e704119eb..6af27d21d5 100755
--- a/src/tools/pgindent/pgperltidy
+++ b/src/tools/pgindent/pgperltidy
@@ -9,4 +9,4 @@ PERLTIDY=${PERLTIDY:-perltidy}
 
 . src/tools/perlcheck/find_perl_files
 
-find_perl_files | xargs $PERLTIDY --profile=src/tools/pgindent/perltidyrc
+find_perl_files "$@" | xargs $PERLTIDY --profile=src/tools/pgindent/perltidyrc
-- 
2.40.1

Reply via email to