Allow and require passing files on command line of pgperltidy
authorPeter Eisentraut <[email protected]>
Wed, 21 Jun 2023 14:14:47 +0000 (16:14 +0200)
committerPeter Eisentraut <[email protected]>
Wed, 21 Jun 2023 14:20:26 +0000 (16:20 +0200)
pgperltidy as well as pgperlcritic and pgperlsyncheck now allow
passing files and directories on the command line, like pgindent does.
(Previously, they would always operate on the whole tree.)

Also, for consistency with pgindent's new behavior (as of b16259b3c1),
passing an argument is now required.  To get the previous default
behavior, use "pgperltidy ." for example.

Discussion: https://www.postgresql.org/message-id/flat/45aacd8a-5265-d9da-8df2-b8e2c0cf6a07%40eisentraut.org

src/tools/perlcheck/find_perl_files
src/tools/perlcheck/pgperlcritic
src/tools/perlcheck/pgperlsyncheck
src/tools/pgindent/README
src/tools/pgindent/pgperltidy

index fd99dab83b0281307b737920b724a0eef899c8cc..20dceb800d0ab034888b352f1606c11bdd52c179 100644 (file)
@@ -3,11 +3,15 @@
 # shell function to find all perl files in the source tree
 
 find_perl_files () {
+   if [ $# -eq 0 ]; then
+       echo 'No files to process' 1>&2
+       return
+   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/'
index 1c2f787580aadf1284d816ad9201be8605a0b4d6..2ec6f20de31576637eb3a776070dd06ff178473a 100755 (executable)
@@ -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
index 730f5927cda7ff3accfe2200de8c4b97e0448f17..da59c9727c07bf5b83ac40335459495dcd63595d 100755 (executable)
@@ -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
index b2b134ee6a250da91ac3835ba62adce21c563bcc..f5fdfc5d2ff1021ec8e93732989d77ff99ab1066 100644 (file)
@@ -45,7 +45,7 @@ DOING THE INDENT RUN:
 
 4) Indent the Perl code using perltidy:
 
-   src/tools/pgindent/pgperltidy
+   src/tools/pgindent/pgperltidy .
 
    If you want to use some perltidy version that's not in your PATH,
    first set the PERLTIDY environment variable to point to it.
index 5e704119eb76626014fe734165a3af96260d6a64..6af27d21d5531322c09a4eafe80950ab8c5e20e6 100755 (executable)
@@ -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