Today I found out (the hard
that the GNU (available on linux) and BSD (available on macOS) implementations
cp behave differently when used to recursively copy.
The differing behaviour comes when running
cp with the
-r flag on a source
directory that ends with a slash (
- GNU/linux: copy the whole directory
- BSD/macOS: copy the contents of the directory
While this is documented behaviour (see man pages below), it can lead to unwanted behaviour if you develop on a mac and build on a linux-based CI system.
-R, -r, --recursive copy directories recursively
-R If source_file designates a directory, cp copies the directory and the entire subtree connected at that point. If the source_file ends in a /, the contents of the directory are copied rather than the directory itself. [...]