Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Mar 2004 22:19:32 +0600
From:      "a.s. mitrohin" <swp@uni-altai.ru>
To:        freebsd-current@freebsd.org
Cc:        Denis Antrushin <DAntrushin@mail.ru>
Subject:   Re: sh bug
Message-ID:  <40645814.7040306@uni-altai.ru>
In-Reply-To: <40628F46.3060900@mail.ru>
References:  <405EFC28.1020905@uni-altai.ru> <20040325035420.GA39519@darkbeer.org> <40628F46.3060900@mail.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Denis Antrushin wrote:
>>> 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. :-)

my "quick fix" here...
http://bspu.secna.ru/~swp/freebsd/patches/sh/patch-cd.c

?

/swp



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