5 ms·
I'm not sure about all languages but this actually caught me by surprise. When you do a 'mv' command (tested on macos) it does not retain file permissions by de
by InitialBP 4y ago
I'm not sure about all languages but this actually caught me by surprise. When you do a 'mv' command (tested on macos) it does not retain file permissions by default. You actually need to pass a special flag in order to do so.
Objective C does retain perms by default using some common move techniques.
- dmd 4y agoWhat? Yes it does. You are confusing mv and cp.
- rileymat2 4y agoThis is a pretty good example. Sure, we should know our tools, but This is not intuitive behavior if you don't know. https://superuser.com/questions/101676/is-there-some-difference-between-mv-and-cp-rm-the-old-file-on-unix https://superuser.com/questions/101676/is-there-some-differe... It is not until the last comment of the accepted answer that you get to the difference in permissions. (along with the answers that are not accepted as best)
- mnw21cam 4y agoOr the parent could be trying to mv a file from one filesystem to another. In that case, mv will have to revert to a copy-then-delete operation, and the user may not have the permissions necessary to set up the new file with all the same metadata as the original.
- dmd 4y agoGood point.
- dahfizz 4y agoWhatever library or tool you use will just call the `rename` syscall. As you would expect, rename simply renames a file. It deletes the old directory entry and creates a new one. If you're using a library or tool to do this for you, you should know what it's doing.