Set exit status for pgindent if pg_bsd_indent fails
authorAndrew Dunstan <[email protected]>
Wed, 8 Jan 2025 15:56:12 +0000 (10:56 -0500)
committerAndrew Dunstan <[email protected]>
Wed, 8 Jan 2025 15:56:12 +0000 (10:56 -0500)
Also document the exit codes in the script.

The new exit code is 3, and is not overridden by the exit code set in
--check mode.

Author: Ashutosh Bapat

Discussion: https://postgr.es/m/CAExHW5sPRSiFeLdP-u1Fa5ba7YS2f0gvLjmKOobopKadJwQ_GQ@mail.gmail.com

src/tools/pgindent/pgindent

index 37eb25d5a86b6da185ce750f5177899cae78874e..d8acce7e9290891c39d44dc75f544d0d05c2c824 100755 (executable)
@@ -2,6 +2,13 @@
 
 # Copyright (c) 2021-2025, PostgreSQL Global Development Group
 
+# Program to maintain uniform layout style in our C code.
+# Exit codes:
+#   0 -- all OK
+#   1 -- error invoking pgindent, nothing done
+#   2 -- --check mode and at least one file requires changes
+#   3 -- pg_bsd_indent failed on at least one file
+
 use strict;
 use warnings FATAL => 'all';
 
@@ -408,6 +415,7 @@ foreach my $source_filename (@files)
        if ($source eq "")
        {
                print STDERR "Failure in $source_filename: " . $error_message . "\n";
+               $status = 3;
                next;
        }
 
@@ -428,7 +436,7 @@ foreach my $source_filename (@files)
 
                        if ($check)
                        {
-                               $status = 2;
+                               $status ||= 2;
                                last unless $diff;
                        }
                }