Am clearly out of my league in these exchanges about possible
implementation. Nevertheless am heartened by
seeing these exchanges.
As to the question that came up in the dialogue:
> Um... don't you mean to use the alias command somewhere, like:
>
> alias popd='builtin popd|tr " " "\n"'
I defined the alias in ~/.bash_aliases
>From one of your initial explanations: that points out that the alias would
be executed in a sub shell, it makes sense
to me that, that approach won't work.
It appears to me that the sub shell does inherit the dirs stack, but any
changes that are made to the dir stack remain
in the sub shell and do not propagate back to the parent shell.
I was thrown off track by:
alias dirs='dirs -v'
But after you explanation of the sub shell execution environment, this
makes sense as dirs does not make any changes
to the dirs stack.
Does the exchanges of your implementation comments mean the possibility of
the addition of the -v option to pushd and
popd are in the realm of possibility?
-Pete
On Tue, Apr 18, 2017 at 11:17 AM, Chet Ramey wrote:
> On 4/18/17 2:13 PM, L A Walsh wrote:
> > Chet Ramey wrote:
> >> On 4/18/17 9:35 AM, Eduardo Bustamante wrote:
> >>
> >>
> >>> Or now that I think about it, you can get away with these functions:
> >>>
> >>> # masked builtins
> >>> dualbus@debian:~/foo/bar/baz$ pushd() { builtin pushd "$@" >/dev/null;
> >>> dirs -v; }; popd(){ builtin popd "$@" >/dev/null; dirs -v; }
> >>>
> >>
> >> This would be the preferable alternative, since it's so trivial. The
> one
> >> change I would suggest would be to make the `;' a `&&':
> >>
> >> pushd()
> >> {
> >> builtin pushd "$@" >/dev/null && dirs -v
> >> }
> >>
> >>
> > Maybe add 'builtin' before "dirs" since we're redefining builtins
> > (i.e. get into habit?)
>
> Sure, if there's a chance there's a function named `dirs' and you *don't*
> want to use it, this is good practice.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~
> chet/
>