Is there a generic way to convert a shell script under MSYS/MinGW into a windows .exe
file (which calls the shell script behind the scene)?
The specific problem I am facing is that I have a shell script lein
from Leiningen (clojure tool chain). I installed it to the default path at /usr/local/bin
(note: I used the shell script version for MSYS, and didn't want to install lein
command outside the MinGW/MSys tree).
Now emacs cider cannot pick up the lein
script although lein
is on the windows path and exec-path
. If I copy lein
into a fake lein.exe
cd /usr/local/bin && cp lein lein.exe
then, cider
recognizes lein.exe
. But of course, cider
couldn't load it because it's not a valid exe
.
Hence, my question. Is there a generic way I can convert a shell script like lein
into a windows executable, e.g. by writing a proxy c++ program?
Thanks.
-- EDIT ---
(Thoughts after seeing the downvotes).
I know this is a corner case and maybe not something you do everyday, and but this is the best solution I can identify so far for making a workable clojure tool chain in MinGW/MSYS.
You originally asked this under the heading "How [can I] convert an MSYS shell script to a Windows .exe?" In my opinion, that's a generally more useful (and quite specific) question to ask, than what you are now asking. On this basis, I will offer an answer to the original question.
I know of no way in which you can simply compile an MSYS shell script, (or indeed any Bourne shell script), into a Windows executable, such that it may be invoked as a child of another executable. However, what you may be able to do is invoke the MSYS shell itself, as the child process, to interpret the script; the syntax you need is:
so, if you can configure your emacs clojure process to invoke the command in this fashion, you may achieve your objective.
A word of caution, however: MSYS commands are intended to be run from within an already running, and properly initialized MSYS parent shell. If emacs is running as a child of such a shell, then this should work okay. However, if emacs is running as a purely native Windows process, outside of an MSYS environment, then you have to take care of initialization[*], when you invoke the child shell. If you see error messages such as "resource unavailable", "resource temporarily unavailable", or "cannot reserve space for cygwin's heap", (yes, MSYS is derived from an early cygwin release, and the text of this message was never changed), that's a fairly certain indicator that the shell environment is not properly initialized.
[*] Effectively, you need to reproduce the initialization steps which are performed by the msys.bat command script, which accompanies any MSYS installation.