delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/09/25/20:19:12

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Jerome Fong <jfong AT successmetricsinc DOT com>
Subject: Re: cygpath -u doesn't seem to convert spaces properly
Date: Tue, 25 Sep 2007 17:18:34 -0700
Lines: 53
Message-ID: <fdc8gq$v1e$1@sea.gmane.org>
References: <fdc59a$ng5$1 AT sea DOT gmane DOT org>
Mime-Version: 1.0
User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)
In-Reply-To: <fdc59a$ng5$1@sea.gmane.org>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

It seems to be a quoting problem.   This is what I was doing:

$ ttt="$(cygpath -u "$JAVA_HOME")"

$ echo $ttt
/cygdrive/c/Program Files/Java/jdk1.5.0_10

$ cd $ttt
bash: cd: /cygdrive/c/Program: No such file or directory

$ cd "$ttt"

$pwd
/cygdrive/c/Program Files/Java/jdk1.5.0_10

Is is possible to setup the variable to not require the double quotes? 
   Since my other method doesn't require the double quotes, it would 
make the scripting much easier.  I wouldn't need to keep track of which 
variables I had to double quote.

$ tttt="$(cygpath -u "$(cygpath -m -s "$JAVA_HOME")")"

$ echo $tttt
/cygdrive/c/PROGRA~1/Java

$ cd $tttt

$ pwd
/cygdrive/c/PROGRA~1/Java

Notice that I can use $tttt directly without have to use the double quote.

thanks,

Jerome

Jerome Fong wrote:
> I am trying to use cygpath -u to convert my windows path to an unix path 
> in my shell script.  However, it has problems with paths that has spaces 
> in it.  For example, "cygpath -u c:\Program Files\Java" is converted to
> /cygdrive/c/Program Files/Java, which doesn't work.  Is there a flag 
> that I am missing?
> 
> I came up with the following, but it seems wrong.
> 
> $ cygpath -u "$(cygpath -m -s "c:\Program Files\Java")"
> /cygdrive/c/PROGRA~1/Java
> 
> Thanks,
> 
> Jerome
> 
> 


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019