On Wed, Nov 6, 2019 at 10:38 PM Kurtis Rader <
kra...@skepticism.us> wrote:
> Thank you, Thomas, for bringing this to our attention. Your bug report is a good example for why I wanted to enable these functions by default in the standard ksh distribution. I am not surprised these functions have bugs. That's because for all intents and purposes no one was using them. Yet they were included in the ksh source code as functions that people should use. Note that these functions, including the `_cd` override are useful, even if you don't like the `pushd`/`popd` pattern (which includes me). Nonetheless, overriding the `cd` builtin is still useful for enabling functions like `mcd` (menu change dir). The solution is to fix the bugs in these long neglected functions -- not to remove them.
Both the way they're included with ksh (in the /examples/ directory)
and especially the way they're presented in the book The New KornShell
Command and Programming Language it's clear that they're example code
people _could_ use rather than _should_ use. On page 267: "This
chapter contains several functions and programs written in the
KornShell language. They are included here primarily for illustrative
purposes. However, you may find some of these functions and/or
programs useful." That said, yes, all these should be made to work,
but it's clear they're opt-in rather than opt-out. The rest of the
KornShell book doesn't use any of the functions in chapter 17 (which
includes dirs, _cd, mcd, popd, and pushd, in nearly the same form as
they're included with ksh)
Also, while that's said, I don't mean to slavishly adhere to the past:
I just don't think it makes sense for these to be enabled by default.
Perhaps better advertising their existence can get more people to use
them! :D
> The `cd` command has to cooperate in maintaining the directory stack for the other functions, such as `mcd`, to work correctly.
Correct.
> I can see the value in that argument. Nonetheless, I think it is noise and should be omitted. The fish shell, which has a `cd` function that augments the `cd` builtin`, does not do this. And that is a far friendlier interactive shall than ksh is.
Not everyone has a perfect memory.
Fortunately, since the _cd command is a shell function, its
customisable by the user. You could comment out the lines that print
the directory when using cd -, while using _cd.