Thread (1 message) 1 message, 1 author, 2016-06-15

Re: t0005-signals.sh fails with ksh

From: Andreas Schwab <hidden>
Date: 2016-06-15 23:04:42

Junio C Hamano [off-list ref] writes:
That is fun.  And doing

    $ mkdir -p git/objects

just before you create and chdir into subdir does tell me that the
last "cd ../.git/objects" is turned into "cd ../git/objects".
This has been fixed in ksh93v.  Looking at the diff between openSUSE
13.1 and 13.2 version of ksh, this hunk from
src/cmd/ksh93/bltins/cd_pwd.c is responsible:
@@ -109,34 +155,22 @@
 		if(!oldpwd)
 			oldpwd = path_pwd(shp,1);
 	}
-	if(*dir=='.')
+	if(dirfd==shp->pwdfd && *dir!='/')
 	{
-		/* test for pathname . ./ .. or ../ */
-		int	n=0;
-		char	*sp;
-		for(dp=dir; *dp=='.'; dp++)
-		{
-			if(*++dp=='.' && (*++dp=='/' || *dp==0))
-				n++;
-			else if(*dp && *dp!='/')
-				break;
-			if(*dp==0)
-				break;
-		}
-		if(n)	
-		{
-			cdpath = 0;
-			sp = oldpwd + strlen(oldpwd);
-			while(n--)
-			{
-				while(--sp > oldpwd && *sp!='/');
-				if(sp==oldpwd)
-					break;
-				
-			}
-			sfwrite(shp->strbuf,oldpwd,sp+1-oldpwd);
-			sfputr(shp->strbuf,dp,0);
-			dir = sfstruse(shp->strbuf);
+		/* check for leading .. */
+
+		char *cp;
+
+		j = sfprintf(shp->strbuf,"%s",dir);
+		cp = sfstruse(shp->strbuf);
+		pathcanon(cp, j + 1, 0);
+		if(cp[0]=='.' && cp[1]=='.' && (cp[2]=='/' || cp[2]==0))
+		{
+			if(!shp->strbuf2)
+				shp->strbuf2 = sfstropen();
+			j = sfprintf(shp->strbuf2,"%s/%s",oldpwd,cp);
+			dir = sfstruse(shp->strbuf2);
+			pathcanon(dir, j + 1, 0);
 		}
 	}
 	rval = -1;

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help