[MacPorts] #62748: reinplace -q: Check if replacement is needed before replacing

MacPorts noreply at macports.org
Mon Apr 26 13:27:48 UTC 2021


#62748: reinplace -q: Check if replacement is needed before replacing
--------------------------+--------------------
  Reporter:  ryandesign   |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.6.4
Resolution:               |   Keywords:
      Port:               |
--------------------------+--------------------

Comment (by ryandesign):

 The reason I can think of off the top of my head is so that we can
 determine afterward if the file got changed or not. But I think we were
 using this method before we were checking whether anything got changed, so
 there may be another reason as well. I haven't looked through the whole
 commit history of the reinplace procedure to find out. The
 [changeset:de81aa779dabc30a20cb21328ba01b4c5c0b3f39/macports-base commit
 that added the reinplace procedure] doesn't mention why it uses a temp
 file rather than `-i`. We could ask Landon but it was 18 years ago so he
 may not remember.

 One possible reason might be that I have never found a portable way to
 specify that no backup file should be created, and perhaps it was desired
 for the code to be portable to Linux systems that tend to use GNU sed even
 if the primary audience is Mac users who have BSD sed. For BSD sed, it
 appears that the arguments must be specified as `-i ""` (with a space
 between the flag and the empty backup filename extension) and for GNU sed,
 it appears that it must be `-i""` (with no space between). Granted this
 difference is something that we could interrogate at configure time and
 write the procedure to use the configuration result accordingly.

 Or we could specify a non-empty backup file extension in the `-i` flag,
 e.g. `-i.orig` or `-i.bak`. (Both GNU sed and BSD sed support this
 notation with no space between when the backup filename extension is not
 empty.) Then we could compare the .orig or .bak file against the modified
 file to see if it was modified. But having sed create the backup file
 would not be significantly different from having MacPorts create the temp
 file, would it?

-- 
Ticket URL: <https://trac.macports.org/ticket/62748#comment:2>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list