Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com From: Mark Hadfield Subject: Re: setting Win32 environment variables in Cygwin Date: Thu, 21 Jul 2005 09:38:02 +1200 Lines: 59 Message-ID: References: <9bbd2794050720120434ea1470 AT mail DOT gmail DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) In-Reply-To: <9bbd2794050720120434ea1470@mail.gmail.com> X-IsSubscribed: yes Alex Goldman wrote: > When I execute a *.bat file containing lines like > > Set FOO=12345 > > FOO does not show up in the environment of the Cygwin shell. Further, > if I execute Win32 programs that access the environment, they can not > see FOO either. It's not clear what you're doing from your description, but if you are opening a Cygwin shell (eg bash), invoking cmd.exe to process the batch file and returning to bash, then you certainly won't see FOO in bash. > Specifically, I need to do > > Set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;%PATH% > Set INCLUDE=C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE% > Set LIB=C:\Program Files\Microsoft Visual Studio .NET > 2003\Vc7\lib;C:\Program Files\Microsoft Visual C++ Toolkit > 2003\lib;%LIB% > > So that VC++ will run properly from the command line. Any suggestions? There was a question in the last day or two about running Digital/Compaq Visual Fortran from a Cygwin shell. My answer pretty much applies here. http://cygwin.com/ml/cygwin/2005-07/msg00849.html I've also expounded on this in the past, mostly in connection with Fortran compilers. A bit of judicious searching might uncover some more info. You should write bash commands to set the environment variables. You can invoke them at the prompt or bundle them in a bash function and invoke that. (It's no good putting them in a shell script and processing it with /bin/bash: it'll all be forgotten when the subprocess exits.) You do have to be careful with characters that need quoting (backslash, semi-colon, space). You also have to allow for the fact that PATH is automagically converted between Unix and Windows forms, but the others aren't. The above link gives an example of how to deal with all these issues. By the way, do you really want to *prepend* entries to the LIB and INCLUDE environment variables (as opposed to starting from scratch)? If so, you'd better make sure the existing variables are in the Windows format expected by your compiler. Ending up with INCLUDE set to something like: C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;/usr/local/include:/usr/include would not be cool. -- Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou" m DOT hadfield AT niwa DOT co DOT nz National Institute for Water and Atmospheric Research (NIWA) -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/