From owner-freebsd-current@FreeBSD.ORG Wed Mar 24 23:52:22 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B556516A4CE for ; Wed, 24 Mar 2004 23:52:22 -0800 (PST) Received: from mail.teledes.ru (host241-net53-vved7.miran.ru [213.221.53.241]) by mx1.FreeBSD.org (Postfix) with ESMTP id DC77E43D39 for ; Wed, 24 Mar 2004 23:52:21 -0800 (PST) (envelope-from DAntrushin@mail.ru) Received: from mail.ru ([10.1.1.31]) (authenticated bits=0) by mail.teledes.ru (8.12.11/8.12.11) with ESMTP id i2P7q3Tx013168 for ; Thu, 25 Mar 2004 10:52:06 +0300 (MSK) Message-ID: <40628F46.3060900@mail.ru> Date: Thu, 25 Mar 2004 10:50:30 +0300 From: Denis Antrushin User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7b) Gecko/20040323 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-current@freebsd.org References: <405EFC28.1020905@uni-altai.ru> <20040325035420.GA39519@darkbeer.org> In-Reply-To: <20040325035420.GA39519@darkbeer.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: sh bug X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Mar 2004 07:52:22 -0000 Amar Takhar wrote: > On 2004-03-22 20:46 +0600, a.s. mitrohin wrote: > >>helo. >> >>builtin cd unable change work directory buf curdir grow anyway. >> > > I found this bug as well years back and ended up mentioning it to Jeff Roberson, > I'm not sure how far he got on figuring out what it was. He did have some > idea's though. It happens in more than just 'sh', sevral shell's have this > issue so i'm not sure that it's a problem with sh. In /usr/src/bin/sh/cd.c (cdlogical(), at line 206): INTOFF; if (updatepwd(badstat ? NULL : dest) < 0 || chdir(curdir) < 0) { INTON; return (-1); } INTON; return(0); Here, updatepwd() updates curdir and prevdir variables and *after* that sh tries to actually change current directory. And when chdir() fails, we don't revert curdir/prevdir changes. :-) > > I'd go with Kris's suggestion and file a PR. > > > Amar.