Re: Access windows environment variable via cygwin

2017-05-12 Thread cyg Simple
On 5/11/2017 9:14 PM, ChampS wrote:
> Hi,
> 
> 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.
> 
> 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.
> 
> Someone an idea how I could solve this issue?
> 

Besides all of the other help already suggested you can also use the 8.3
format of the directory name to remove the spaces from PATH in your
Windows environment variable.  Then Cygwin will not see the spaces
either.  The use of 8.3 format is configurable and you may need to turn
it on for the drive.  Use the "dir /X" cmd.exe command to see if you
have the 8.3 name.

-- 
cyg Simple

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



Re: Access windows environment variable via cygwin

2017-05-12 Thread Jim Reisert AD1C
On Thu, May 11, 2017 at 9:07 PM, Brian Inglis wrote:

> Cygwin has no problem with paths containing spaces.

That may be somewhat of an oversimplification.  Due to the way we do
backups at work, my Cygwin "root" is installed in a path that contains
spaces.  Most things work OK, but Xwin is unable to automatically run
"xrdb" when it starts up.  This means that my default X program
configurations (xterm , Emacs) are not read.  I have to manually run
xrdb each time I start a new Xwin session.  It's not the end of the
world, but it does require a little extra work each time.

- Jim

-- 
Jim Reisert AD1C, , http://www.ad1c.us

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



Re: Access windows environment variable via cygwin

2017-05-12 Thread Brian Inglis
On 2017-05-12 06:23, Andrey Repin wrote:
>>> 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".
> Correction: You should always use proper quoting, even if you 100% know the
> variable content is "safe", unless the results of not using quoting are
> actually desired.

There's lots of contexts where you don't need quoting, as the shell uses the 
variable and contents and does the right thing, but there is no easy way to 
describe this, other than quote where there are shell parameter expansions, 
which may not mean much to many.

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



Re: Access windows environment variable via cygwin

2017-05-12 Thread Andrey Repin
Greetings, Brian Inglis!

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

Correction: You should always use proper quoting, even if you 100% know the
variable content is "safe", unless the results of not using quoting are
actually desired.


-- 
With best regards,
Andrey Repin
Friday, May 12, 2017 15:22:17

Sorry for my terrible english...


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



Re: Access windows environment variable via cygwin

2017-05-11 Thread Larry Hall (Cygwin)

On 05/11/2017 10:44 PM, Eliot Moss wrote:

On 5/11/2017 9:14 PM, ChampS wrote:

Hi,

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.

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.

Someone an idea how I could solve this issue?


Yeah, spaces are hell in paths in the Posix/Linux kind of world.


Really, they are just as bad in the Windows world, as one quickly finds out
if you're at a command prompt.  Just as spaces in path and file names need
to be escaped in POSIX/Linux/Unix and like environments, Windows requires
the same thing.  It just uses different syntax for doing so.  But that's
OK.  Without all this complication, using computers would be no fun at all.
;-)

--
Larry

_

A: Yes.
> Q: Are you sure?
>> A: Because it reverses the logical flow of conversation.
>>> Q: Why is top posting annoying in email?

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



Re: Access windows environment variable via cygwin

2017-05-11 Thread Brian Inglis
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



Re: Access windows environment variable via cygwin

2017-05-11 Thread Eliot Moss

On 5/11/2017 9:14 PM, ChampS wrote:

Hi,

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.

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.

Someone an idea how I could solve this issue?


Yeah, spaces are hell in paths in the Posix/Linux kind of world.

What you need is to "protect" the spaces with \ or have them inside a quoted 
string.
Also, items in a path need to be separated by : and not ; 

This mostly has to do with understanding how strings, quoting, etc., work in
the Unix world and for bash in particular.  Over time I have developed methods
that work with these things that have space in them. For example, to add 
something
to the end of PATH:

PATH="${PATH}:/my/new/thing"

Here the quotes are important!  And they need to be " quotes not ' quotes!
( ' quotes would not allow ${PATH} to be expanded, while " quotes do allow 
that.)
Etc.

Regards - Eliot Moss

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