delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/02/09/10:51:14

X-Spam-Check-By: sourceware.org
Date: Thu, 9 Feb 2006 10:51:05 -0500 (EST)
From: Igor Peshansky <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: jgriffin <jgriffin AT pclnet DOT net>
cc: cygwin AT cygwin DOT com
Subject: Re: Paths and Cygwin
In-Reply-To: <20060209145338.M55639@pclnet.net>
Message-ID: <Pine.GSO.4.63.0602091039220.6049@access1.cims.nyu.edu>
References: <20060209145338 DOT M55639 AT pclnet DOT net>
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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

On Thu, 9 Feb 2006, jgriffin wrote:

(Reordered for more logical flow of the reply).

> Why does Cygwin append a extra backslash to the path?

Don't you mean "prepend an extra slash"?  Backslash is a '\'.
Cygwin doesn't -- it's a bug in your script (run it with "bash -x") to
confirm.  In fact, you also have a couple of potential bugs there...

> I'm trying to run this script:
> [snip]
> 	IFS=/
> 	set x $directory

This will set $1 to "" (since "$directory" is absolute).  See (*) below.

> 	case $2 in
> 	    */*)	# IFS parsing is broken
> 		IFS=' '
> 		set x `echo $directory | tr / ' '`

This will not work for filenames with spaces in them.

> 		;;
> 	esac
>
> 	for filename
> 	do
> 		path=$prefix$filename

On the first iteration, this appends a "" (your empty first argument) to
"/" (your prefix).

> 		prefix=$path/

(*) And this is where the prefix becomes "//" (the original "/" plus the
"/" you use for the path separator).

> [snip]
> 			mkdir $paths || status=$?

You might want to add some quoting here too.  Oh, and this will overwrite
$status with that of the last failed mkdir.

> Input: ./mkdirhier.sh "/home/jgriffin/test/level1/level2" >& out.txt
> [snip]
> Here's the output:
> prefix: /
> mkdir: cannot create directory `//home': No such file or directory

None of the above is Cygwin-specific, BTW -- except for the fact that
Linux will treat a leading "//" as a "/" (masking the bug), and Cygwin
interprets it as a network share prefix (also, filenames with spaces are a
bit more common on Cygwin).
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"

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