When trying to execute a bash script, it is often execute inside some directory, and requires access to local resources. I was wondering if there was a way to combine both the bash script and the resources (everything else in the directory) into an executable, so that I would only need that executable stand-alone to execute the bash script.
You probably should not combine a Bash script into an executable, for these reasons, but if you absolutely need an executable, you can use SHC (technically an obfuscation algorithm). SHC "translates" the script into C code, and then compiles it.
We then come to the problem of the multiple files. Because SHC can only take one file as input, you will have to combine all the files into one. Obviously this is not possible, because if it was, you would have already done that, but, you can move all the other files to one location, and then have the main program call those files.
Another more advisable alternative is to move all the needed files into one directory, and then write a separate program that calls them all. For example, if your program requires three files,
z.txt, you can write another script,
n, that calls
y can call
z.txt, because they are in the same directory.
Simply mark the main program (
n in the example) as executable, and then move it to whatever location you need it to be in. Because the location of the needed files do not change, no matter where you move the main file, it can always access the others.
This inevitably falls short of your intended goal, but is as close as possible. If you need the "needed files" to access a file wherever you move the program to, you can simply have the main program pass that file's name as a command line argument. If needed, you can write the main program in C so that it is an executable binary file, although I realize that was not your original goal, may conserve time and space in the calling procedures.