1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +00:00

Fix for no-argument use of 'cd' in .../fun/dirs

'cd' with no argument is supposed to go to your home directory, but
in this override function it produced an error due to an incorrect
use of $@ within another parameter substitution, preventing $@ from
expanding to zero words.

Ref.: https://groups.google.com/d/msgid/korn-shell/781ed34b-6860-5d47-dfe8-be21280a6b31%40inlv.org

src/cmd/ksh93/fun/dirs: _cd():
- Fix the bug by setting a positional parameter if needed,
  then using a normal and correct "$@" expansion for \cd.
- While we're here, restore a historic comment about using
  'command' to bypass aliases that exists in the listing of this
  function in the official 1995 KornShell book (pp. 274-276).
  Presumably, that comment was deleted when they decided to add the
  obnoxious and broken default alias command='command ', whenever
  that was. This branch got rid of that default alias in 61d9bca5.
This commit is contained in:
Martijn Dekker 2020-06-14 10:24:05 +02:00
parent d66f2a80d8
commit 6109f54a5e

View file

@ -55,7 +55,11 @@ function _cd
case $dir in
\~*) dir=$HOME${dir#\~}
esac
\cd "${dir:-$@}" >| /dev/null || return 1
# If there are no arguments, use $dir if non-empty.
(($#)) || set -- ${dir:+"$dir"}
# \cd prevents alias substitution.
# You can use command cd with 12/28/93 and newer.
\cd "$@" >| /dev/null || return 1
dir=${OLDPWD#$HOME/}
case $TERM in
630)