mirror of
https://github.com/postgres/postgres.git
synced 2026-04-20 22:00:13 -04:00
pgindent: Always clean up .BAK files from pg_bsd_indent
The previous commit let pgindent clean up File::Temp files on SIGINT. This extends that to also cleaning up the .BAK files, created by pg_bsd_indent. Author: Jelte Fennema-Nio <postgres@jeltef.nl> Discussion: https://www.postgresql.org/message-id/flat/DFCDD5H4J7VX.3GJKRBBDCKQ86@jeltef.nl
This commit is contained in:
parent
801de0bd44
commit
6857947db5
1 changed files with 10 additions and 1 deletions
|
|
@ -28,6 +28,12 @@ use Getopt::Long;
|
|||
$SIG{INT} = sub { exit 130; }; # 128 + 2 (SIGINT)
|
||||
$SIG{TERM} = sub { exit 143; }; # 128 + 15 (SIGTERM)
|
||||
|
||||
# pg_bsd_indent creates a .BAK file that File::Temp doesn't know about. This
|
||||
# END block makes sure that that file is cleaned up in case someone presses
|
||||
# Ctrl+C during pgindent.
|
||||
my $bak_to_cleanup;
|
||||
END { unlink $bak_to_cleanup if defined $bak_to_cleanup; }
|
||||
|
||||
# Update for pg_bsd_indent version
|
||||
my $INDENT_VERSION = "2.1.2";
|
||||
|
||||
|
|
@ -296,11 +302,14 @@ sub run_indent
|
|||
print $tmp_fh $source;
|
||||
$tmp_fh->close();
|
||||
|
||||
$bak_to_cleanup = "$filename.BAK";
|
||||
|
||||
$$error_message = `$cmd $filename 2>&1`;
|
||||
|
||||
return "" if ($? || length($$error_message) > 0);
|
||||
|
||||
unlink "$filename.BAK";
|
||||
unlink $bak_to_cleanup;
|
||||
$bak_to_cleanup = undef;
|
||||
|
||||
open(my $src_out, '<', $filename) || die $!;
|
||||
local ($/) = undef;
|
||||
|
|
|
|||
Loading…
Reference in a new issue