1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

whence -a/type -a: report both function and built-in by same name

'whence -a' is documented to list all possible interpretations of a
command, but failed to list a built-in command if a shell function
by the same name exists or is marked undefined using 'autoload'.

src/cmd/ksh93/bltins/whence.c: whence():
- Refactor and separate the code for reporting functions and
  built-in commands so that both can be reported for one name.

src/cmd/ksh93/data/builtins.c: sh_optwhence[]:
- Correct 'whence --man' to document that:
  * 'type' is equivalent to 'whence -v'
  * '-a' output is like '-v'

src/cmd/ksh93/tests/builtins.sh:
- Test 'whence -a' with these combinations:
  * a function, built-in and external command
  * an undefined/autoload function, built-in and external command

Fixes https://github.com/ksh93/ksh/issues/83
This commit is contained in:
Martijn Dekker 2020-07-20 19:49:32 +01:00
parent 01c25cb14b
commit bc8b36faba
5 changed files with 45 additions and 20 deletions

View file

@ -2017,9 +2017,9 @@ _JOB_
;
const char sh_optwhence[] =
"[-1c?\n@(#)$Id: whence (AT&T Research) 2007-04-24 $\n]"
"[-1c?\n@(#)$Id: whence (AT&T Research/ksh93) 2020-07-20 $\n]"
USAGE_LICENSE
"[+NAME?whence - locate a command and describe its type]"
"[+NAME?whence, type - locate a command and describe its type]"
"[+DESCRIPTION?Without \b-v\b, \bwhence\b writes on standard output an "
"absolute pathname, if any, corresponding to \aname\a based "
"on the complete search order that the shell uses. If \aname\a "
@ -2027,7 +2027,8 @@ USAGE_LICENSE
"[+?If \b-v\b is specified, the output will also contain information "
"that indicates how the given \aname\a would be interpreted by "
"the shell in the current execution environment.]"
"[a?Displays all uses for each \aname\a rather than the first.]"
"[+?The \btype\b command is equivalent to \bwhence -v\b.]"
"[a?Like \b-v\b but displays all uses for each \aname\a rather than the first.]"
"[f?Do not check for functions.]"
"[p?Do not check to see if \aname\a is a reserved word, a built-in, "
"an alias, or a function. This turns off the \b-v\b option.]"