Re: sed --in-place bug (updates mtime of file even if no changes are made)

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Organization Red Hat
Message-ID <[email protected]>
On 11/08/2011 02:32 PM, John Vanderpool wrote:
> --in-place shouldn't update the mtime of the file if the pattern doesn't
> match
> (i.e. no changes were made to file)

Why not?  Conceptually, 'sed --in-place' is short-hand for 'sed > temp,
mv temp original', since it is not possible to known a priori whether
the sed script will modify the input when generating the temporary file.

You're welcome to submit a patch if you think you can fix it, but right
now, I don't think sed should have to recognize whether the output is
identical to the input.  If you need mtime unchanged, then use sed to a
temporary file yourself, and compare the two files before deciding
whether to move the temporary file or keep the original.

-- 
Eric Blake   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc (application/pgp-signature, 620 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBCAAGBQJOvb9hAAoJEKeha0olJ0NqTLkH/i7wA12I5GHaEvfqJGamUJC5
UKUJNFgFq8ZJO6m3zRVA7b3V4cgh3ohPzf1bAZJPIxW8tGg+JbvJSJCc9E2BkppV
lAwIwD3P9QFn4Wtg29+C8x8gvry1W3NONWQU9WOzohmX3ph5XsBmgZmKYloMeqwt
1oovWD5+/y+bFCceU5VVpcAuehBZjTa0xMOw5/vO5iCQNRgzrSkVuMGbjsszdyy6
0A4XZSGkDSC9nWeSsN/t03X6BJNDya5AaTSzTCToNiJF2FS0yKD/1EUfCIJOWnEx
v0rD8o0uOglErPXMNVH5UIr9Q+cuSus/a/5SnX0eJfQ1mYTAFhtxttNS2CG1+VQ=
=dTwX
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.