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 LAA05033 for ; Thu, 17 Oct 1996 11:08:36 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id VAA01792; Wed, 16 Oct 1996 21:04:41 -0400 (EDT) Resent-Date: Wed, 16 Oct 1996 20:57:52 -0400 (EDT) Date: Wed, 16 Oct 1996 17:56:33 -0700 Message-Id: <199610170056.RAA09115@kontiki.Eng.Sun.COM> From: John S Cooper To: schaefer@nbn.com Cc: John S Cooper , zsh-users@math.gatech.edu Subject: Re: `popd' is blocked on non-existent directory In-Reply-To: <961015222654.ZM27814@candle.brasslantern.com> References: <199610160202.TAA04520@kontiki.Eng.Sun.COM> <961015222654.ZM27814@candle.brasslantern.com> X-Attribution: JSC X-Mailer: VM 5.96 (beta) under 19.14 XEmacs Lucid Mime-Version: 1.0 (generated by tm-edit 7.89) Content-Type: multipart/mixed; boundary="Vivre_La_France_Wed_Oct_16_17:56:32_1996-1" Content-Transfer-Encoding: 7bit Resent-Message-ID: <"Ba5nu3.0.jP.FIOPo"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/438 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu --Vivre_La_France_Wed_Oct_16_17:56:32_1996-1 Content-Type: text/plain; charset=US-ASCII Bart Schaefer writes: > 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.) Thanks. I've added a little code to do what you suggest and have popd also honor the PUSHD_TO_HOME option. Now, if you popd when there's a single dirstack entry and PUSHD_TO_HOME is set, it'll pop you to your home directory: 160 kontiki%> setopt pushdtohome 162 kontiki%> dirs /usr/bin /tmp 163 kontiki%> dirs ~ /usr/bin /tmp 164 kontiki%> popd /usr/bin /tmp 165 kontiki%> popd /tmp 165 kontiki%> popd ~ .. and with pushdtohome unset: 156 kontiki%> unsetopt pushdtohome 157 kontiki%> dirs /usr/bin /tmp 158 kontiki%> dirs ~ /usr/bin /tmp 159 kontiki%> popd /usr/bin /tmp 160 kontiki%> popd /tmp 160 kontiki%> popd popd: directory stack empty I've attached the diffs (which include your changes): --Vivre_La_France_Wed_Oct_16_17:56:32_1996-1 Content-Type: text/plain; charset=US-ASCII *** builtin.c Wed Oct 16 17:31:48 1996 --- builtin.c.orig Wed Oct 16 16:11:23 1996 *************** *** 998,1018 **** char *dest; if (!argv[0]) { - if (func == BIN_POPD && !nextnode(firstnode(dirstack))) { - if (unset(PUSHDTOHOME)) { - zwarnnam(nam, "directory stack empty", NULL, 0); - return NULL; - } - else { - pushnode(dirstack, ztrdup(home)); - dir = nextnode(firstnode(dirstack)); - } - } if (func == BIN_PUSHD && unset(PUSHDTOHOME)) dir = nextnode(firstnode(dirstack)); if (dir) insertlinknode(dirstack, dir, getlinknode(dirstack)); ! else if (func != BIN_POPD) pushnode(dirstack, ztrdup(home)); } else if (!argv[1]) { int dd; --- 998,1008 ---- char *dest; if (!argv[0]) { if (func == BIN_PUSHD && unset(PUSHDTOHOME)) dir = nextnode(firstnode(dirstack)); if (dir) insertlinknode(dirstack, dir, getlinknode(dirstack)); ! else pushnode(dirstack, ztrdup(home)); } else if (!argv[1]) { int dd; *************** *** 1058,1063 **** --- 1048,1054 ---- target = dir; if (func == BIN_POPD) { if (!dir) { + zsfree(getlinknode(dirstack)); target = dir = firstnode(dirstack); } else if (dir != firstnode(dirstack)) { return dir; *************** *** 1070,1077 **** 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)) { --- 1061,1066 ---- --Vivre_La_France_Wed_Oct_16_17:56:32_1996-1--