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

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <46F9AA3C.3227153@dessent.net>
Date: Tue, 25 Sep 2007 17:39:24 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: cygpath -u doesn't seem to convert spaces properly
References: <fdc59a$ng5$1 AT sea DOT gmane DOT org> <fdc8gq$v1e$1 AT sea DOT gmane DOT org>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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

Jerome Fong wrote:

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

Yes, that's wrong.  But more importantly, it's not wrong just in the
POSIX/Win32 path sense, it's wrong in the sense that it can't cope with
any argument that contains whitespace.  Your script would also fail on a
Linux system that for example had a directory like "~/some files" -- and
in that case there is no 8.3 short filename hack to save you, so there
is no avoiding the need for proper quoting.  It's got nothing to do with
cygpath and everything to do with proper portable scripting practice.

> Is is possible to setup the variable to not require the double quotes?

Only if you neglect to support filenames and paths with spaces in them.

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

Easier perhaps but still broken.

Brian

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