Handling permissions to run a bash script

I'm sending a bash script as a .command file to a friend. This person is not very tech savvy which is why I'm sending it in the first place, the goal is for the .command file to run through the shell operations for them. However when the attempt to run the script they get the run.command is damaged and can't be opened. You should move it to the Bin error. I believe this is a new version of the old unsigned developer prompt as apple is blocking out random code from their systems. Anyway I can have this run without too much complexity?

Edit: I'm open to using applescript if this will alleviate the issue.


AppleScript

Wrap the shell script in a do shell script AppleScript command:

do shell script "say \"hello world\""

If your script needs administrator rights, append with administrator privileges to the command:

do shell script "say \"goodbye moon\"" with administrator privileges

Using Script Editor.app in /Applications/Utilities, you can save the AppleScript as a .applescript text file that will launch in Script Editor on the host computer.

The end user will need to select the menu item:

  • Script (menu) > Run

Alternatively, you can Export as an Application and code sign the resulting application. This assumes you have a code signing certificate available.

Script Editor's Export dialog on macOS

Automator

An Automator workflow can also include shell scripts and AppleScripts. Automator can also save as an application, with the Export… menu item also prompting to code sign the result for you.