This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Access windows environment variable via cygwin


On 2017-05-11 19:14, ChampS wrote:
> I want to use Cygwin to access all Windows applications installed on
> my Windows 7 system. The Problem is that Windows is using spaces in
> its environment variable 'Path' and Cygwin can not handle the spaces.
> Is there a way to use the Windows environment variable 'Path' even
> with spaces in it? For Example I want to start x86 sbt via Cygwin,
> then I will get the following error message: "/cygdrive/c/Program
> Files (x86)/sbt/bin/sbt: line 61: /sbt-launch-lib.bash: No such file
> or directory". But when I try it with the default Windows cmd it
> works.

Cygwin has no problem with paths containing spaces.
Windows cmd will launch Windows programs in the registry even if their 
bin directories are not in your PATH, as will cygstart; otherwise  
Cygwin requires either that bin directories are in your PATH, or that 
you specify the full path to the executable when you run any program, 
and if there any spaces or other shell special characters in the full 
path, they needs quoted; quoting can use prefix \ or quotes e.g.
	/cygdrive/c/Program\ Files\ \(x86\)/sbt/bin/sbt
	'/cygdrive/c/Program Files (x86)/sbt/bin/sbt' as in ls or
	"/cygdrive/c/Program Files (x86)/sbt/bin/sbt". 

> Thought about something like iterating over the 'Path' environment
> variable in bashrc and adapt the strings to fit for Cygwin. But I
> don't know how I can access the Windows environment variables and how
> I could provide the adapted environment variable to Cygwin.

Cygwin automatically converts all directories in your PATH 
when you start a process.
>From bash, echo "$PATH", to see what Cygwin has done.
Base utility cygpath -p allows you to do this on your own Windows 
environment variables like $CLASSPATH etc. as long as you properly 
quote the conversion e.g. 

$ CLASSPATH='C:\Program Files\Java;C:\Program Files (x86)\Java'
$ cp="$(cygpath -Up "$CLASSPATH")"
$ echo "$cp"
/proc/cygdrive/c/Program Files/Java:/proc/cygdrive/c/Program Files (x86)/Java
 
> Someone an idea how I could solve this issue?

If your scripts use environment variables, they should be careful 
to enclose uses of those variables in double quotes "$VAR".

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]