|
From: | Tim Nielens |
Subject: | Re: Subject: Manual directory stack ambiguity |
Date: | Sun, 16 Aug 2015 23:40:52 +0200 |
On 8/14/15 6:08 AM, Tim Nielens wrote:
> Bash Version: 4.3
> Patch Level: 39
> Release Status: release
>
> Description:
> There is a ambiguity about the directory stack in the manual: 6.8.1
> Directory Stack Builtins
>
> It's difficult to understand if the current directory is part of the stack
> or not.
`dirs' always displays the directory stack, and the current directory is
always the first element (sometimes the only one).
The current directory is always the implicit top of the directory stack,
so things like popd and pushd without arguments can use it, so `dirs' lists
it as the first element.
When you use pushd for the first time, for instance, you push the directory
given as an argument `on top' of the current directory, and make it the
new current directory, so it's the top of the stack for a subsequent pushd
or popd.
If you haven't pushed anything, there's nothing to pop, and `popd' returns
an error message. If you have pushed something, you pop the current
directory and return to the immediately previous one.
pushd always changes the current directory unless the -n option is given.
Since the `topmost' element of the stack is always the current directory,
popd will change the current directory if it operates on the top element
(popd, popd +0), unless the -n option is given.
Since a successful `pushd' or `popd' always prints the contents of the
directory stack, there should not be too much confusion about its members.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
[Prev in Thread] | Current Thread | [Next in Thread] |