I don't know if this affects MacOS versions newer than High Sierra, but it seems that cp -p
won't preserve timestamps with nanoseconds resolution.
Because of this, the shell can wrongly tell that a file is older than other even if it was copied by cp -p
. This breaks build system dependencies when some files were installed by cp -p
: they keep reinstalling and reinstalling again because the nanoseconds don't match.
Can you suggest some workaround for this? I thought compiling my own cp
binary, but however cp
is usually a shell builtin, and moreover I'm not aware of any nanosecond-preserving cp
version out there.
Note: I know of a workaround, but it's not reasonable: Execute touch
on the source file before executing cp -p
. Because touch
doesn't preserve nanoseconds either, it makes them zero on the source file, so the result after cp -p
guarantees exactly the same timestamp. However, as I said, it's not reasonable, because I don't like to touch
files just for this: you lose their real last saved date.