Subject: Re: bug#49287: sed -i disrespects read-only

From: Assaf Gordon <[email-masked]>
Date: Wed, 4 Aug 2021 15:17:50 -0600

tag 49287 notabug
close 49287
stop

Hello,

On 2021-07-01 7:22 a.m., Davide Brini wrote:
> On Wed, 30 Jun 2021 08:01:13 +0200, Leonid Mironov <[email-masked]> wrote:
> 
>>     sed disrespects read-only file attributes when editing in place.
>>
> 
> Well tecnically this is correct since sed never writes to the
> original file, instead it creates a new file, writes to it and finally
> renames it to the old name, so the original file permissions never come
> into play (in case you're wondering: it's not really "in-place").
> 
> I agree it could be surprising, but once you know how it works behind
> the scenes it should make a bit more sense.
> 

Thank you Davide for answering.

I would like to emphasize that this should *not* be surprising,
as it the way UNIX file and directory permissions have always worked -
this has nothing to do with sed.

Please see similar (and more detailed) discussion about it here:
   https://lists.gnu.org/archive/html/bug-sed/2017-06/msg00000.html

Please see here for in-depth examples of how "in-place" is not so trivial:
   http://www.pixelbeat.org/docs/unix_file_replacement.html

regards,
  -assaf