views:

93

answers:

1

I want to initialize my Cygwin environment with a variable coming from a batch file

@set myvar=test
%BASH% --login -c "set"
REM hope to see myvar

So I want myvar with its value eventually be available in bash.

A: 

You can have the batch file append your variable to your bash.bashrc file to create bash environmental variables, like so:

export croot=/cygdrive/c

Then you access that croot variable like so

export cc=$croot/CC

or

alias cdcc='cd $croot/CC'

The path on my machine is C:\cygwin\etc\bash.bashrc ... yours may differ.

Note that the variable won't be available in running cygwin sessions, only new ones.

Robusto
Running the batch multiple times then clutters the initialization script for bash, though.
Joey
not a good way...
Michael