Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Mar 2004 10:50:30 +0300
From:      Denis Antrushin <DAntrushin@mail.ru>
To:        freebsd-current@freebsd.org
Subject:   Re: sh bug
Message-ID:  <40628F46.3060900@mail.ru>
In-Reply-To: <20040325035420.GA39519@darkbeer.org>
References:  <405EFC28.1020905@uni-altai.ru> <20040325035420.GA39519@darkbeer.org>

next in thread | previous in thread | raw e-mail | index | archive | help


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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40628F46.3060900>