diff --git a/src/cmd/ksh93/bltins/whence.c b/src/cmd/ksh93/bltins/whence.c index 35b09aeed..300194c12 100644 --- a/src/cmd/ksh93/bltins/whence.c +++ b/src/cmd/ksh93/bltins/whence.c @@ -250,8 +250,6 @@ static int whence(Shell_t *shp,char **argv, register int flags) const char *command_path = np->nvalue.pathcomp->name; sfprintf(sfstdout,"%s %s %s/%s\n",name,sh_translate(is_talias),command_path,cp); } - else if(!np || nv_isnull(np)) - sfprintf(sfstdout,"%s%s\n",name,sh_translate(is_ufunction)); continue; } sfputr(sfstdout,sh_fmtq(name),' '); diff --git a/src/cmd/ksh93/tests/builtins.sh b/src/cmd/ksh93/tests/builtins.sh index fbc658a65..b9d9e297c 100755 --- a/src/cmd/ksh93/tests/builtins.sh +++ b/src/cmd/ksh93/tests/builtins.sh @@ -732,20 +732,27 @@ foo=BUG command eval ':' [[ $foo == BUG ]] && err_exit '`command` fails to disable the special properties of special builtins' # ====== -# `whence -a` should not base the path of tracked aliases on the current directory -run_whence() -{ - whence -a chmod >> /dev/null +# 'whence -a' tests + +# wrong path to tracked aliases after loading builtin: https://github.com/ksh93/ksh/pull/25 +actual=$("$SHELL" -c ' + whence chmod >/dev/null # add to hash table (create tracked alias) builtin chmod whence -a chmod -} -actual="$(run_whence)" +') expected="chmod is a shell builtin $(whence -a -p chmod | sed 's/^/chmod is /') chmod is a tracked alias for $(whence -p chmod)" [[ $actual == $expected ]] || err_exit "'whence -a' does not work correctly with tracked aliases" \ "(expected $(printf %q "$expected"), got $(printf %q "$actual"))" +# spurious 'undefined function' message: https://github.com/ksh93/ksh/issues/26 +actual=$("$SHELL" -c 'whence -a printf') +expected="printf is a shell builtin +$(whence -a -p printf | sed 's/^/printf is /')" +[[ $actual == $expected ]] || err_exit "'whence -a': incorrect output" \ + "(expected $(printf %q "$expected"), got $(printf %q "$actual"))" + # ====== # 'cd ../.foo' should not exclude the '.' in '.foo' (