Re: pgindent exit status if a file encounters an error

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgindent exit status if a file encounters an error
Date: 2024-06-26 13:28:12
Message-ID: CAExHW5tLPEpgjaeNUYWKsB8FgCOuenr6+MTCyoj-ME4LEmdjfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Andrew,
Thanks for the quick review.

On Wed, Jun 26, 2024 at 4:53 PM Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

>
> With --check option pgindent reports a non-zero exit code instead of
> making changes. So I feel the above change should happen at least if
> --check is provided. But certainly better if we do it even without --check.
>
> In case --check is specified and both the following happen a.
> pg_bsd_indent exits with non-zero status while processing some file and b.
> changes are produced while processing some other file, the program will
> exit with status 2. It may be argued that instead it should exit with code
> 3. I am open to both.
>
>
> Yeah, I think this is reasonable but we should adjust the status setting a
> few lines lower to
>
>
> $status ||= 2;
>

So you are suggesting that status 3 is preferred over status 2 when both
are applicable. I am fine with that.

Here's what the behaviour looks like: (notice echo $? after running
pgindent)

1. Running without --check, if pgindent encounters file processing errors,
exit code is 3.
2. Running with --check, exit code depends upon whether pgindent encounters
a file with processing error first or a file that undergoes a change.
a. If it encounters a file that would undergo a change first, exit
status is 2
b. If it encounters a file with processing error first, exit status is 3
3. If --check is specified and no file undergoes a change, but there are
file processing errors, it will exit with code 3.

The variation in the second case based on the order of files processed
looks fine to me. What do you say?

The usage help mentions exit code 2 specifically while describing --check
option but it doesn't mention exit code 1. Neither does the README. So I
don't think we need to document exit code 3 anywhere. Please let me know if
you think otherwise.

--
Best Wishes,
Ashutosh Bapat

Attachment Content-Type Size
0001-pgindent-exit-status-on-error-20240626.patch text/x-patch 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2024-06-26 13:36:10 Re: Should we document how column DEFAULT expressions work?
Previous Message ikedarintarof 2024-06-26 12:52:55 doc: modify the comment in function libpqrcv_check_conninfo()