Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get Cygwin to accurately read my Windows environment variables?

I'm using Windows XP with the latest version of Cygwin. If I set the following environment variable in my Windows system

JBOSS_HOME=C:/Program Files/jboss-4.2.3.GA

and then fire up Cygwin, I'm unable to switch to the inherited $JBOSS_HOME directory.

$ cd $JBOSS_HOME
cygwin warning:
  MS-DOS style path detected: C:/Program
  Preferred POSIX equivalent is: /cygdrive/c/Program
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
-bash: cd: C:/Program: No such file or directory

Is it possible to define my system variable once in the Windows environment and then get Cygwin to interpret it so that I don't get this "No such file or directory" warning?

like image 254
Dave A Avatar asked Aug 15 '12 15:08

Dave A


2 Answers

You could do one of two things...

  • Add a command to convert the path in your .bashrc file, like so...

export JBOSS_HOME=$( cygpath "$JBOSS_HOME" )

or

  • Just put the variable between quotes when referencing it, since Cygwin understands DOS style paths, even though it doesn't prefer them. The reason the command is failing for you is that there is a space in the path, so putting it in quotes will get the path to be read correctly as one arg...

cd "$JBOSS_HOME"

Note that you might still get that same "cygwin warning" in this case. In order to make that go away, you need to add nodosfilewarning to your CYGWIN var as the warning advises. You can do that by adding this in your .bashrc file...

export CYGWIN="${CYGWIN} nodosfilewarning"

like image 188
Costa Avatar answered Sep 28 '22 03:09

Costa


I am using Eclispse with ShellED plugins,

I got the same notification, not knowing the accurate configuration,

I just add the export value into the script

'#!/bin/bash'

export CYGWIN="${CYGWIN} nodosfilewarning"

echo hello
like image 20
user2427719 Avatar answered Sep 28 '22 05:09

user2427719