Different behavior: Finder Copy vs 'cp' command

I am working on a bug in our deployment script for our organization.

The step in question copies an entire directory of apps that do not have their own PKG installers:

cp -rf /Volumes/DEPLOY/apps/ /Volumes/Macintosh\ HD/Applications/


This step worked fine on macOS 12 but is no longer functioning as intended on macOS 13.

When this deploy script is run, the applications are copied but Finder tells me that the apps are "damaged" and forces them to be deleted (even though the OS fails to delete them and they must be cleaned up manually).

Copying the entire folder of apps via the Finder into the Applications folder works fine, and the apps aren't damaged when copied in this manner.


The script is being deployed as sudo in order to invoke 'installer' to install the remaining PKG files as well as Rosetta.


Is there a reason that these applications do not copy properly with the 'cp' command in zsh, and if so- what is the proper syntax to copy this folder so that the entire app is copied and the OS does not consider the app "damaged"?

Posted on Jun 26, 2023 11:58 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 1, 2023 7:33 PM

2 suggestions.


cp -r -p -f ...


The -p preserves permissions, which for applications is very important as you want executable files to remain executable.


My second suggestion is to use ditto instead of cp, as ditto is what Apple uses to unpack .pkg files.

man ditto

Similar questions

4 replies

Jul 1, 2023 5:56 PM in response to Randall_2023

Randall_2023 wrote:

I'm not an expert at Terminal level scripting but know a tiny bit. This part doesn't look right to me:
"/Volumes/Macintosh\ HD/Applications/"

Because the hard drive name by default is "Macintosh HD" so shouldn't it read....
cp -rf /Volumes/DEPLOY/apps/ '/Volumes/Macintosh HD/Applications/'

FYI, The OP has the format correct because you must escape the spaces in the path by using a backslash before a space. Another option if you want to keep the same human readable format as seen in the Finder, then you can enclose the path in double quotes.


For example, the following two paths are equivalent:


Escaping the space by using the backslash:

ls  /Volumes/Macintosh\ HD/Applications


Enclosing the path in double quotes so the space can be written without any modifications other than the enclosing double quotes:

ls  "/Volumes/Macintosh HD/Applications"




This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Different behavior: Finder Copy vs 'cp' command

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.