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

Don't detect unset functions with whence (re: 13c57e4b) (#287)

src/cmd/ksh93/bltins/whence.c:
- The previous commit that fixed 'unset -f' in virtual subshells left
  one bug. The type builtin (or 'whence -v') could still find the unset
  function in virtual subshells:
    $ foo() { echo foo; }
    $ (unset -f foo; type foo)
    foo is an undefined function
  To fix this bug, avoid detecting functions in the whence builtin
  unless they have the NV_FUNCTION flag.

src/cmd/ksh93/tests/subshell.sh:
- Add a regression test for using 'type' on a function unset inside of
  a virtual subshell.
This commit is contained in:
Johnothan King 2021-04-24 13:25:45 -07:00 committed by GitHub
parent 07faf38425
commit 24b7fcb771
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -192,7 +192,7 @@ static int whence(Shell_t *shp,char **argv, register int flags)
}
/* built-ins and functions next */
bltins:
if(!(flags&F_FLAG) && (np = nv_bfsearch(name, shp->fun_tree, &nq, &notused)) && !is_abuiltin(np))
if(!(flags&F_FLAG) && (np = nv_bfsearch(name, shp->fun_tree, &nq, &notused)) && is_afunction(np))
{
if(flags&Q_FLAG)
continue;