[PATCH imake 4/4] mkdirheir: ignore empty components created by extra slashes

Yaakov (Cygwin/X) yselkowitz at users.sourceforge.net
Tue Apr 27 17:40:55 PDT 2010


From: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>

POSIX.1-2008 Base Definitions 4.12 ("Pathname Resolution") states:

"A pathname that begins with two successive <slash> characters may be
interpreted in an implementation-defined manner, although more than two
leading <slash> characters shall be treated as a single <slash>
character."

On Cygwin, paths with exactly two leading slashes are mapped to their
backslash-subsituted Windows UNC equivalents.  Therefore "/usr" and
"//usr" are explicitely not the same path, while "/usr/foo" and
"/usr//foo" are, as on other platforms.

We must therefore ignore the empty '' component created from the leading
slash.  While it is not strictly necessary later on, it does not hurt to
ignore extra slashes either.

Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
---
 mkdirhier |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/mkdirhier b/mkdirhier
index 09b89ee..c33c389 100644
--- a/mkdirhier
+++ b/mkdirhier
@@ -43,6 +43,10 @@ do
 
 	for filename
 	do
+		if [ "$filename" = '' ]; then
+			continue
+		fi
+
 		path=$prefix$filename
 		prefix=$path/
 		shift
-- 
1.7.0.4



More information about the xorg-devel mailing list