Re: pgindent exit status if a file encounters an error

Поиск
Список
Период
Сортировка
От Ashutosh Bapat
Тема Re: pgindent exit status if a file encounters an error
Дата
Msg-id CAExHW5tLPEpgjaeNUYWKsB8FgCOuenr6+MTCyoj-ME4LEmdjfg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pgindent exit status if a file encounters an error  (Andrew Dunstan <andrew@dunslane.net>)
Ответы Re: pgindent exit status if a file encounters an error
Список pgsql-hackers
Hi Andrew,
Thanks for the quick review.

On Wed, Jun 26, 2024 at 4:53 PM Andrew Dunstan <andrew@dunslane.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
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: ikedarintarof
Дата:
Сообщение: doc: modify the comment in function libpqrcv_check_conninfo()
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Should we document how column DEFAULT expressions work?