From 6109f54a5e238645438f5d210b7909777a2a2435 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Sun, 14 Jun 2020 10:24:05 +0200 Subject: [PATCH] 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. --- src/cmd/ksh93/fun/dirs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/ksh93/fun/dirs b/src/cmd/ksh93/fun/dirs index 0329970f3..a08a0ae55 100755 --- a/src/cmd/ksh93/fun/dirs +++ b/src/cmd/ksh93/fun/dirs @@ -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)