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:
parent
01c25cb14b
commit
bc8b36faba
5 changed files with 45 additions and 20 deletions
|
@ -138,7 +138,6 @@ static int whence(Shell_t *shp,char **argv, register int flags)
|
|||
register int aflag,r=0;
|
||||
register const char *msg;
|
||||
int tofree;
|
||||
Dt_t *root;
|
||||
Namval_t *nq;
|
||||
char *notused;
|
||||
Pathcomp_t *pp=0;
|
||||
|
@ -181,32 +180,36 @@ static int whence(Shell_t *shp,char **argv, register int flags)
|
|||
}
|
||||
/* built-ins and functions next */
|
||||
bltins:
|
||||
root = (flags&F_FLAG)?shp->bltin_tree:shp->fun_tree;
|
||||
if(np= nv_bfsearch(name, root, &nq, ¬used))
|
||||
if(!(flags&F_FLAG) && (np = nv_bfsearch(name, shp->fun_tree, &nq, ¬used)) && !is_abuiltin(np))
|
||||
{
|
||||
if(is_abuiltin(np) && nv_isnull(np))
|
||||
goto search;
|
||||
cp = "";
|
||||
if(flags&V_FLAG)
|
||||
{
|
||||
if(nv_isnull(np))
|
||||
cp = sh_translate(is_ufunction);
|
||||
else if(is_abuiltin(np))
|
||||
{
|
||||
if(nv_isattr(np,BLT_SPC))
|
||||
cp = sh_translate(is_spcbuiltin);
|
||||
else
|
||||
cp = sh_translate(is_builtin);
|
||||
}
|
||||
else
|
||||
cp = sh_translate(is_function);
|
||||
}
|
||||
else
|
||||
cp = "";
|
||||
if(flags&Q_FLAG)
|
||||
continue;
|
||||
sfprintf(sfstdout,"%s%s\n",name,cp);
|
||||
if(!aflag)
|
||||
continue;
|
||||
aflag++;
|
||||
}
|
||||
if((np = nv_bfsearch(name, shp->bltin_tree, &nq, ¬used)) && !nv_isnull(np))
|
||||
{
|
||||
if(flags&V_FLAG)
|
||||
if(nv_isattr(np,BLT_SPC))
|
||||
cp = sh_translate(is_spcbuiltin);
|
||||
else
|
||||
cp = sh_translate(is_builtin);
|
||||
else
|
||||
cp = "";
|
||||
if(flags&Q_FLAG)
|
||||
continue;
|
||||
sfprintf(sfstdout,"%s%s\n",name,cp);
|
||||
if(!aflag)
|
||||
continue;
|
||||
cp = 0;
|
||||
aflag++;
|
||||
}
|
||||
search:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue