git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: t0005-signals.sh fails with ksh

From
Andreas Schwab <schwab@linux-m68k.org>
Date
May 9, 2015, 08:20 UTC
Message-ID
<m2h9rmupq5.fsf@linux-m68k.org>
In-Reply-To
<xmqqk2wiiwa3.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> 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."
Previous: evgenyNext: Junio C Hamano
Message 7 of 11 in “t0005-signals.sh fails with ksh”
  1. evgenyMay 8, 2015
  2. Junio C HamanoMay 8, 2015
  3. Jeff KingMay 8, 2015
  4. Jeff KingMay 8, 2015
  5. Junio C HamanoMay 8, 2015
  6. evgenyMay 8, 2015
  7. Andreas SchwabMay 9, 2015
  8. Junio C HamanoMay 8, 2015
  9. Jeff KingMay 8, 2015
  10. brian m. carlsonMay 9, 2015
  11. evgenyMay 8, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.