How can I set up a shell script as a wrapper to the main executable of an app? I have an application that I want to launch via a shell script that does some setup and then launches the app itself with some specific options. Ideally, this script would be run whenever the application would normally be launched, i.e. when I click on it in the dock, double-click in the Applications folder, launch from QS, or even click on a file that opens in this app.

Right now I have an applescript wrapper "App" for my script, but the downside is that it appears as a separate app from the main app that sits in my dock, so I have to remember to not click on the main app's icon, but launch this alternate app instead. 

So is this something that is possible to do? One idea I had is to rename the main executable in the app to something else, and then replace it with my script. Is that a reasonable thing to do, or is there a better solution?

For those who are curious, I am trying to set up Emacs.app to launch a daemon and then open using emacsclient. Basically, I want to have this script launch instead of emacs (and I'm going to modify the script to take file arguments and open them as well).
Use /Applications/Emacs.app/Contents/MacOS/Emacs (or other executable in that directory). 

Generally, application bundles are structured as above. Use Terminal to 'ls' your way to the file.