Convert bash script to a compiled standalone binary executable, not text I want to make a Bash script executable by the kernel. I have already used the chmod +x command and #!/bin/bash to make it executable and it works, but that I want to do is make it an executable without an interpreter, like an executable from a compiled app.
Is there any way I can do this? All I need is a way to make by Bash script executable from the macOS kernel itself and I do not need to specify a shebang. I also do not want anyone to be able to open it with text edit or similar and be able to see the code.
I would take a look at a project named shc (Shell script compiler).
https://github.com/neurobin/shc
It takes a shell script and compiles it into C source code. The C source code can then be compiled with a standard C compiler into a binary executable.
This allows you to run the script you've made without the contents of the shell script being immediately revealed in clear text. It would be a binary executable like so many others.
It might take a bit of trial and error to get your specific script parsed by shc depending on how advanced features you're using in your bash script, but this should take you most of the way there.
Note that the program really just encrypts your shell script and integrates it within the binary. When the binary is executed, the script is decrypted and executed using ordinary shell again. For programmers it would be trivial to break this to reveal the contents of your script, but for hiding the script contents from the average home user it would perhaps be sufficient.
If you have HomeBrew installed, you can install shc by running the following command in the Terminal:
brew install shc

Then it's just a matter of running shc to convert your script into a binary:
shc -U -f myscript.sh -o mybinary

The mybinary command is then the finished product.