Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Dec 2003 20:10:20 -0800 (PST)
From:      "Danny J. Zerkel" <dzerkel@columbus.rr.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/59530: strange bug in /bin/sh
Message-ID:  <200312200410.hBK4AKcN011028@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/59530; it has been noted by GNATS.

From: "Danny J. Zerkel" <dzerkel@columbus.rr.com>
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 23:04:16 -0500

 On further review, PWD and OLDPWD are not correctly handled by my
 previous patch.  So I offer the following update, which only sets
 the environment variables only if we succeed in changing directory:
 
 *** cd.c.orig   Fri Dec 19 22:51:26 2003
 --- cd.c        Fri Dec 19 22:57:58 2003
 ***************
 *** 155,160 ****
 --- 155,163 ----
          if ((phys || cdlogical(dest) < 0) && cdphysical(dest) < 0)
                  return (-1);
 
 +       setvar("PWD", curdir, VEXPORT);
 +       setvar("OLDPWD", prevdir, VEXPORT);
 +
          if (print && iflag && curdir)
                  out1fmt("%s\n", curdir);
 
 ***************
 *** 217,223 ****
    {
 
          INTOFF;
 !       if (chdir(dest) < 0 || updatepwd(NULL) < 0) {
                  INTON;
                  return (-1);
          }
 --- 220,231 ----
    {
 
          INTOFF;
 !       if (chdir(dest) < 0) {
 !               updatepwd(NULL);
 !               INTON;
 !               return (-1);
 !       }
 !       if (updatepwd(NULL) < 0) {
                  INTON;
                  return (-1);
          }
 ***************
 *** 278,285 ****
                          INTON;
                          return (-1);
                  }
 -               setvar("PWD", curdir, VEXPORT);
 -               setvar("OLDPWD", prevdir, VEXPORT);
                  INTON;
                  return (0);
          }
 --- 286,291 ----
 ***************
 *** 310,317 ****
                  ckfree(prevdir);
          prevdir = curdir;
          curdir = savestr(stackblock());
 -       setvar("PWD", curdir, VEXPORT);
 -       setvar("OLDPWD", prevdir, VEXPORT);
          INTON;
 
          return (0);
 --- 316,321 ----
 
 Danny J. Zerkel -- dzerkel@columbus.rr.com



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