[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#49287: sed -i disrespects read-only
From: |
Davide Brini |
Subject: |
bug#49287: sed -i disrespects read-only |
Date: |
Thu, 1 Jul 2021 15:22:07 +0200 |
On Wed, 30 Jun 2021 08:01:13 +0200, Leonid Mironov <lvm@royal.net> wrote:
> Hello,
>
> sed disrespects read-only file attributes when editing in place.
>
> $ ls -l testfile*
> -r--r--r-- 1 lvm lvm 50 Jun 30 08:32 testfile
> $ sed 's/test/bug/g' -i~ testfile
> $ diff testfile testfile~
> 2c2
> < this is a bug
> ---
> > this is a test
> $ sed --version
> sed (GNU sed) 4.4
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.
--
D.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#49287: sed -i disrespects read-only,
Davide Brini <=