[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why sed -i does not respect the w mode?
From: |
Peng Yu |
Subject: |
Re: Why sed -i does not respect the w mode? |
Date: |
Thu, 29 Dec 2022 11:14:19 -0600 |
However, the intent of -w is to forbid any changes to it. How sed does
it internally is irrelevant to users. It appears to users that sed
changes the file unexpectedly. Thus, I think that sed should first
check the write permission before doing anything to the file.
On 12/29/22, Davide Brini <dave_br@gmx.com> wrote:
> On Wed, 28 Dec 2022 18:34:39 -0600, Peng Yu <pengyu.ut@gmail.com> wrote:
>
>> Hi,
>>
>> I turned off w of test.txt. But it still can be changed by sed -i.
>> Should sed -i respect the w mode?
>
> Whether the source file is writable or not doesn't matter to sed, since
> it's never written to. With -i, sed creates a temporary file which is
> renamed to the original name at the end (for both things, what matters are
> the permissions on the containing directory, not those of the file).
>
> --
> D.
>
>
--
Regards,
Peng