From 7a0f65a2367885eea0c9b7a4257e6faf758f58eb Mon Sep 17 00:00:00 2001 From: Ashutosh Bapat Date: Wed, 26 Jun 2024 15:46:53 +0530 Subject: [PATCH 1/2] pgindent exit status on error When pg_bsd_indent exits with a non-zero status or reports an error, make pgindent exit with non-zero status 3. The program does not exit on the first instance of the error. Instead it continues to process remaining files as long as some other exit condition is encountered, in which case exit code 3 is reported. This helps to detect errors automatically when pgindent is run in shells which interpret non-zero exit status as failure. Author: Ashutosh Bapat Reviewed by: Andrew Dunstan Discussion: https://www.postgresql.org/message-id/CAExHW5sPRSiFeLdP-u1Fa5ba7YS2f0gvLjmKOobopKadJwQ_GQ@mail.gmail.com --- src/tools/pgindent/pgindent | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 48d83bc434..c9a8fd6561 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -409,6 +409,7 @@ foreach my $source_filename (@files) if ($source eq "") { print STDERR "Failure in $source_filename: " . $error_message . "\n"; + $status = 3; next; } @@ -429,7 +430,7 @@ foreach my $source_filename (@files) if ($check) { - $status = 2; + $status ||= 2; last unless $diff; } } -- 2.34.1