First, I think there may be a bug. Did you intend that appending empty data would always append a newline, such that the file grows by one newline every time? It's consistent with the new documentation but not with what you wrote above ("If the file does exist and it's opened for append then the modtime on the file will NOT be updated."). I think it makes more sense to append a trailing newline only when new data was added, and the attached patch implements this (along with the rest) and documents it.
On Tue, Jan 31, 2012 at 1:16 AM, Paul Smith <psm...@gnu.org> wrote: > The problem, as I alluded to before, is that there's no way to get the > exact semantics of updating a file without actually updating the file. > > In order to change the modtime on a file without changing the file you > have to use utime()... Yes, this is something you and I discussed a while ago in a different context. What I'm thinking of doesn't involve utime and is illustrated by the attached patch. In the special case where $(file) is appending an empty string to an existing file, it reads one byte and writes it back. This gives timestamp semantics identical to an actual write, because it is an actual write. And it's safely atomic because the file has the same contents whether the write succeeds or fails. A proof-of-concept patch is attached along with a demo makefile. -David Boyce
Makefile
Description: Binary data
func_file-dsb.diff
Description: Binary data
_______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make