]> git.donarmstrong.com Git - perltidy.git/commitdiff
update comments and docs
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 11 Jul 2022 13:59:28 +0000 (06:59 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 11 Jul 2022 13:59:28 +0000 (06:59 -0700)
CHANGES.md
bin/perltidy
lib/Perl/Tidy.pm

index b6f32d1356c01ab95109172aad02f3bea789fc0e..b14107f326ec81d0dbcbb3a7fa4dcca08be8f999 100644 (file)
@@ -2,6 +2,20 @@
 
 ## 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
index 40b3a967f954ca70ea1a214765ff693483f8f6b1..d7c57b58f2fd9eae3a62f222a1bdc3d09df60ce1 100755 (executable)
@@ -243,6 +243,11 @@ extension F<.bak>.  Any existing F<.bak> file will be deleted.  See next
 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.
 
index d908a9b6b2624d2baf29ebdc18105157971550ac..b49abd29b4930877a19e6a71e261c5a3a35d1a30 100644 (file)
@@ -1159,11 +1159,9 @@ sub backup_method_copy {
     $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"
       );
@@ -1206,8 +1204,8 @@ EOM
       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 );