From owner-freebsd-bugs@FreeBSD.ORG Fri Dec 19 19:54:16 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2802916A4CE for ; Fri, 19 Dec 2003 19:54:16 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 08C1143DD9 for ; Fri, 19 Dec 2003 19:51:16 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) hBK3oLFR007408 for ; Fri, 19 Dec 2003 19:50:21 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id hBK3oLst007406; Fri, 19 Dec 2003 19:50:21 -0800 (PST) (envelope-from gnats) Date: Fri, 19 Dec 2003 19:50:21 -0800 (PST) Message-Id: <200312200350.hBK3oLst007406@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: "Danny J. Zerkel" Subject: Re: bin/59530: strange bug in /bin/sh X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Danny J. Zerkel" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Dec 2003 03:54:16 -0000 The following reply was made to PR bin/59530; it has been noted by GNATS. From: "Danny J. Zerkel" To: freebsd-gnats-submit@FreeBSD.org, dima@KOT.SPb.Ru Cc: Subject: Re: bin/59530: strange bug in /bin/sh Date: Fri, 19 Dec 2003 22:45:38 -0500 Unfortunately, updatepwd() is what changes curdir to make the chdir(curdir) attempt to go to the new directory. Doing the chdir() first, means don't go anywhere, just update where we think we are. I think the real problem is that the chdir() failure fall back is cdphysical(), which if the chdir() fails MUST do updatepwd(NULL). So this patch appears to work correctly: *** cd.c.orig Fri Dec 19 22:01:40 2003 --- cd.c Fri Dec 19 22:36:33 2003 *************** *** 217,223 **** { INTOFF; ! if (chdir(dest) < 0 || updatepwd(NULL) < 0) { INTON; return (-1); } --- 217,228 ---- { INTOFF; ! if (chdir(dest) < 0) { ! updatepwd(NULL); ! INTON; ! return (-1); ! } ! if (updatepwd(NULL) < 0) { INTON; return (-1); } Danny J. Zerkel -- dzerkel@columbus.rr.com