From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-request@euclid.skiles.gatech.edu Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id PAA28006 for ; Wed, 16 Oct 1996 15:34:18 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id BAA10917; Wed, 16 Oct 1996 01:30:29 -0400 (EDT) Resent-Date: Wed, 16 Oct 1996 01:23:55 -0400 (EDT) From: "Bart Schaefer" Message-Id: <961015222654.ZM27814@candle.brasslantern.com> Date: Tue, 15 Oct 1996 22:26:54 -0700 In-Reply-To: John S Cooper "`popd' is blocked on non-existent directory" (Oct 15, 7:02pm) References: <199610160202.TAA04520@kontiki.Eng.Sun.COM> Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.820 20aug96) To: John S Cooper , zsh-users@math.gatech.edu Subject: Re: `popd' is blocked on non-existent directory MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"y-XUt2.0.6f2.h57Po"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/437 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Oct 15, 7:02pm, John S Cooper wrote: } Subject: `popd' is blocked on non-existent directory } } Under zsh 3.0.0, if a directory in the directory stack is removed, popd } seems to get "blocked". In 2.5, the non-existent directory would just be } removed from the stack. } } Is there a way to get the old behavior, i.e. have all non-existent } directories removed from the stack? --- Src/builtin.c.0 Tue Oct 8 10:30:08 1996 +++ Src/builtin.c Tue Oct 15 21:23:49 1996 @@ -1082,6 +1082,8 @@ if (!(dest = cd_do_chdir(nam, getdata(dir)))) { if (!target) zsfree(getlinknode(dirstack)); + if (func == BIN_POPD) + zsfree(remnode(dirstack, dir)); return NULL; } if (dest != getdata(dir)) { } Also, when there's only one entry left on the dir stack, (I think) a popd } used to remove it and pop me to my home directory. This is no longer the } case in 3.0.0 . The compatible-with-other-shells behavior in this case would be to issue a `directory stack empty' error message. (However, I could see an argument that PUSHD_TO_HOME ought to apply to popd as well.) What the code is actually doing is pushing the home directory onto the stack (without actually doing the chdir) and then popping it back off again. Then it executes chdir to the top of the stack, that is, to the directory it's already in: zagzig[65] ./zsh -f zagzig% chpwd() { echo CHPWD } zagzig% popd /usr/src/local/zsh/zsh-3.0.1-test3/Src CHPWD zagzig% popd /usr/src/local/zsh/zsh-3.0.1-test3/Src CHPWD This seems like a lot of wasted effort, particularly considering that chpwd gets run each time. --- Src/builtin.c.0 Tue Oct 8 10:30:08 1996 +++ Src/builtin.c Tue Oct 15 22:20:21 1996 @@ -1019,11 +1019,15 @@ char *dest; if (!argv[0]) { + if (func == BIN_POPD && !nextnode(firstnode(dirstack))) { + zwarnnam(nam, "directory stack empty", NULL, 0); + return NULL; + } if (func == BIN_PUSHD && unset(PUSHDTOHOME)) dir = nextnode(firstnode(dirstack)); if (dir) insertlinknode(dirstack, dir, getlinknode(dirstack)); - else + else if (func != BIN_POPD) pushnode(dirstack, ztrdup(home)); } else if (!argv[1]) { int dd; @@ -1069,7 +1073,6 @@ target = dir; if (func == BIN_POPD) { if (!dir) { - zsfree(getlinknode(dirstack)); target = dir = firstnode(dirstack); } else if (dir != firstnode(dirstack)) { return dir; -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.nbn.com/people/lantern New male in /home/schaefer: >N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"