Source a .bat file from bash

Earnie Boyd earnie@users.sourceforge.net
Mon Aug 12 14:33:00 GMT 2013


On Mon, Aug 12, 2013 at 4:18 AM, Csaba Raduly <rcsaba@gmail.com> wrote:
> Hi Saurabh,
>
> On Fri, Aug 9, 2013 at 10:42 PM, Saurabh T wrote:
>> Is there a way to source a .bat file from bash and have the paths and other environment variables set in it apply in cygwin?
>>
>
> Note that "to source" in UNIX shell parlance means "read the file and
> interpret it". Bash can't do that with a .bat file (it's in a
> different language).
>

That is only half true.  I have and a little success with bash reading
a .bat file but you must obey the rules of bash syntax or overcome it
and vice versa.  Tedious at best.

> You could run cmd.exe to interpret the .bat file, but changes to th
> environment get lost when cmd.exe exits. One possibility is to run
> bash from the cmd.exe window after the batch has finished.
>

Or just start a Cygwin shell from the .bat file.  That child of the
.bat file would contain the environment from the parent but the parent
cannot receive the environment of the child.

-- 
Earnie
-- https://sites.google.com/site/earnieboyd

--
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