how to embed shell script within a .BAT file

Andrey Repin anrdaemon@yandex.ru
Sun Nov 9 22:05:00 GMT 2014


Greetings, Nellis, Kenneth!

> I'm tired of creating pairs of script files:  a clickable .BAT file 
> to invoke my shell script and then my shell script to do the actual
> work.

google: cygwin shell wrapper script
I posted mine in the mailing list not once, and it's not the only available
solution.

> I was wondering if any of the geniuses on this list have come
> up with a way to embed a shell script inside a clickable .BAT file.

It is technically possible to invoke specific processor for a bat file, but no
Cygwin tools understand the necessary syntax. Your only option is to create
proper association(s) for your favorite extensions.

FTYPE unixshell.script="C:\Programs\Cygwin_64\bin\env.exe" -- /bin/cygwrap.sh "%1" %*
ASSOC .sh=unixshell.script
ASSOC .awk=unixshell.script
ASSOC .pl=unixshell.script
ASSOC .whatver=unixshell.script

The wrapper is as simple as

-------->8-------->8-------->8-------->8--------
#!/bin/sh

test -z "$1" && exit 1

/bin/env -- "$(cygpath -au "$1")" "${@:2}"
--------8<--------8<--------8<--------8<--------

Don't forget to add your favorite extensions to PATHEXT, else you won't be
able to run them scripts from CMD.


--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 10.11.2014, <00:51>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list