how to embed shell script within a .BAT file
Tue Nov 11 16:12:00 GMT 2014
> From: Achim Gratz
> Nellis, Kenneth writes:
> > Jeremy's solution is closest to what I was looking for; however I need
> > it to work from a networked, non-drive-mapped folder.
> > (CMD.EXE doesn't like UNC paths.) I hadn't realized that I could pipe
> > a script into bash.
> The solution to the UNC path problem is to put something
> PUSHD %~dp0
> near the beginning of the script. That is if you really want to have .bat
> files and click on them in Explorer. Associating the shell scripts
> properly so that Explorer will hand them to Cygwin sounds like a better
> solution to me.
BTW, works great! Here's the completed .BAT file preface with added error
handling so the CMD window doesn't auto-close if the bash code exits with
type %0 | sed "0,/^---BASH SCRIPT FOLLOWS---/ d; s/\r*$//" | bash
if errorlevel 1 pause
---BASH SCRIPT FOLLOWS---
I'll pursue associating a shell script with a file type
when I have more time.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin