[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed -i should require write access (was: Bug in sed)
From: |
Bob Proulx |
Subject: |
Re: sed -i should require write access (was: Bug in sed) |
Date: |
Tue, 28 Dec 2010 11:08:27 -0700 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Paul Eggert wrote:
> Bob Proulx wrote:
> > That is the way Unix filesystem permissions work.
>
> Yes, but still, it's bogus that "sed -i" overwrites a
> read-only file. That's not what users expect, and it's
> not what the documentation says. The documentation
> says that -i "overwrites the file in place", which implies
> that you must have write access to the file.
Changing this behavior would make sed incompatible with perl. I think
in this case since perl is the grandfather of this functionality that
keeping in close sync with perl is important. It drives what is
expected behavior.
echo "hello world" > file
chmod a=r file
perl -pi -e s/hello/my/ file
Also changing this after all of this time would almost certainly come
as a surprise to people who are using the current behavior. Suddenly
scripts that have been working successfully to edit files will stop
working. That is going to greatly irritate them.
> How about the following patch, to fix this?
Note that I didn't look at the patch itself.
Bob