## 2022 06 13.01
+ - Fix for issue git #103. For parameter -b, or --backup-and-modify-in-place,
+ the default backup method has been changed to preserve the inode value
+ of the file being formatted. If this causes a problem, the previous
+ method is available and can be used by setting -backup-mode='move', or
+ -bm='move'. The new default corresponds to -bm='copy'. The difference
+ between the two methods is as follows. For the older method,
+ -bm='move', the input file was moved to the backup, and a new file was
+ created for the formatted output. This caused the inode to change. For
+ the new default method, -bm='copy', the input is copied to the backup
+ and then the input file is reopened and rewritten. This preserves the
+ file inode. Before using the --backup-and-modify-in-place
+ parameter please verify that it works correctly in your environment and
+ operating system.
+
- Fix undefined value message when perltidy -D is used (git #104)
- Added parameter --delete-repeated-commas (-drc) to delete repeated
item for changing the default backup extension, and for eliminating the
backup file altogether.
+B<Please Note>: Writing back to the input file increases the risk of data loss
+or corruption in the event of a software or hardware malfunction. Before using
+the B<-b> parameter please be sure to have backups and verify that it works
+correctly in your environment and operating system.
+
A B<-b> flag will be ignored if input is from standard input or goes to
standard output, or if the B<-html> flag is set.
$self->set_output_file_permissions( $backup_file, \@input_file_stat,
$in_place_modify );
- # Open a file with the original input file name for writing ... Opening
- # with either ">" or "+>" should truncate the existing data. The '+>'
- # indicates that we may also read, even though there will be nothing left
- # to read, which might help insure that we get the same inode.
- open( my $fout, "+>", $input_file )
+ # Open the original input file for writing ... opening with ">" will
+ # truncate the existing data.
+ open( my $fout, ">", $input_file )
|| Die(
"problem re-opening $input_file for write for -b option; check file and directory permissions: $ERRNO\n"
);
or Die("cannot close '$input_file' with -b option: $OS_ERROR\n");
# Set permissions of the output file to match the input file. This is
- # necessary even if the inode remains unchanged. In particular,
- # the suid/sgid bits may have changed.
+ # necessary even if the inode remains unchanged because suid/sgid bits may
+ # have been reset.
$self->set_output_file_permissions( $input_file, \@input_file_stat,
$in_place_modify );