Paths and Cygwin

Igor Peshansky pechtcha@cs.nyu.edu
Thu Feb 9 16:33:00 GMT 2006


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@cs.nyu.edu | igor@watson.ibm.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/


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /