* 'pushd +2' rotates rather than extracts @ 2004-06-16 21:48 Dave Yost 2004-06-17 3:35 ` Vincent Stemen 2004-06-17 5:13 ` Bart Schaefer 0 siblings, 2 replies; 4+ messages in thread From: Dave Yost @ 2004-06-16 21:48 UTC (permalink / raw) To: zsh-workers This is how tcsh works with 'dextract' set: % dirs /tmp/a /tmp/b /tmp/c /tmp/d /tmp/e % pushd +2 0 /tmp/c 1 /tmp/a 2 /tmp/b 3 /tmp/d 4 /tmp/e That is also how I believe zsh is documented to work (and how I would like it to work). But here is what zsh does: 202 Z% echo $ZSH_VERSION 4.2.0 Z% dirs /tmp/a /tmp/b /tmp/c /tmp/d /tmp/e Z% pushd +2 /tmp/c /tmp/d /tmp/e /tmp/a /tmp/b Z% ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 'pushd +2' rotates rather than extracts 2004-06-16 21:48 'pushd +2' rotates rather than extracts Dave Yost @ 2004-06-17 3:35 ` Vincent Stemen 2004-06-17 5:13 ` Bart Schaefer 1 sibling, 0 replies; 4+ messages in thread From: Vincent Stemen @ 2004-06-17 3:35 UTC (permalink / raw) To: zsh-workers On Wed, Jun 16, 2004 at 02:48:32PM -0700, Dave Yost wrote: > This is how tcsh works with 'dextract' set: > > % dirs > /tmp/a /tmp/b /tmp/c /tmp/d /tmp/e > % pushd +2 > 0 /tmp/c > 1 /tmp/a > 2 /tmp/b > 3 /tmp/d > 4 /tmp/e > > That is also how I believe zsh is documented to work (and how I would like it to work). > > But here is what zsh does: > > 202 Z% echo $ZSH_VERSION > 4.2.0 > Z% dirs > /tmp/a /tmp/b /tmp/c /tmp/d /tmp/e > Z% pushd +2 > /tmp/c /tmp/d /tmp/e /tmp/a /tmp/b > Z% It also seems to me it should work the way tcsh does as shown above. I have noticed that the directory stack did not behave as I would expect for quite a while and rarely use it with numbered arguments because of that. I just have not bothered to take the time to look closely at what it was doing before now. Dave pinpointed the problem. Looks like it moves the entire rest of stack to the top rather than the single entry like it does when used with no arguments. It does it on zsh-4.1.1 also. -- Vincent Stemen Avoid the VeriSign/Network Solutions domain registration trap! Read how Network Solutions (NSI) was involved in stealing our domain name. http://www.InetAddresses.net ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 'pushd +2' rotates rather than extracts 2004-06-16 21:48 'pushd +2' rotates rather than extracts Dave Yost 2004-06-17 3:35 ` Vincent Stemen @ 2004-06-17 5:13 ` Bart Schaefer 2004-06-17 7:17 ` Vincent Stemen 1 sibling, 1 reply; 4+ messages in thread From: Bart Schaefer @ 2004-06-17 5:13 UTC (permalink / raw) To: zsh-workers According to the documentation (man zshbuiltins): The third form of pushd changes directory by rotating the directory list. And then in Functions/Example/pushd, which unfortunately is not referenced in the User Contributions section of the manual, one finds: # pushd function to emulate the old zsh behaviour. With this function # pushd +/-n just lifts the selected element to the top of the stack # instead of just cycling the stack. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 'pushd +2' rotates rather than extracts 2004-06-17 5:13 ` Bart Schaefer @ 2004-06-17 7:17 ` Vincent Stemen 0 siblings, 0 replies; 4+ messages in thread From: Vincent Stemen @ 2004-06-17 7:17 UTC (permalink / raw) To: zsh-workers On Wed, Jun 16, 2004 at 10:13:13PM -0700, Bart Schaefer wrote: > According to the documentation (man zshbuiltins): > > The third form of pushd changes directory by rotating the > directory list. > > And then in Functions/Example/pushd, which unfortunately is not referenced > in the User Contributions section of the manual, one finds: > > # pushd function to emulate the old zsh behaviour. With this function > # pushd +/-n just lifts the selected element to the top of the stack > # instead of just cycling the stack. > Hmm. So it is intentional. I can see how the zsh behavior could be useful. I guess I need try it out for a while, now that I realize what it's doing, and see how I like it. I have found that when zsh does something different, it is usually (aways?) an improvement :-). Although, since it is a deviation from the traditional way of handling the directory stack, it might be a good idea to make it YAZO (Yet Another Zsh Option :-)) to be able to switch to the old behavior. If anything, it would make it better documented for others who don't know about it. The zshoptions manual is often the first place I look when I find something does not behave the way I expect. I almost always end up staying with the "improved" zsh behavior but it is often handy to have that choice. Also, just as a suggestion for improving the manual, just saying it rotates the directory list was not really clear to me that this is different from other shells. Perhaps it would be good to add an example similar to what Dave Yost wrote or to re-word it to clarify that, unlike other shells, it rotates the entire stack to the top rather than just the one entry. Regards, Vincent -- Vincent Stemen Avoid the VeriSign/Network Solutions domain registration trap! Read how Network Solutions (NSI) was involved in stealing our domain name. http://www.InetAddresses.net ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-06-17 7:17 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-06-16 21:48 'pushd +2' rotates rather than extracts Dave Yost 2004-06-17 3:35 ` Vincent Stemen 2004-06-17 5:13 ` Bart Schaefer 2004-06-17 7:17 ` Vincent Stemen
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).