Discussion:
[ast-developers] strange behavior for KSH (in AST-OPEN 2014-12-24)
David A.D. Morano, PE, PhD
2015-04-28 15:51:56 UTC
Permalink
There is some (seemingly) very strange behavior with KSH 2014-12-24.

The behavior of the 'whence' KSH (built-in) command has often
been quite mysterious so I am not sure if this is new errant behavior
or possibly old errant behavior.

Scenario:

1) load a user-defined builtin-in (let us call it 'ourbuiltin')

2) execute:
$ whence -a ourbuiltin
output is:
ourbuiltin is a shell builtin
ourbuiltin is /usr/add-on/local/bin/ourbuiltin
ourbuiltin is /usr/extra/bin/ourbuiltin
ourbuiltin is an undefined function

3) analysis:
The first three lines above seem correct. in addition to
the name 'ourbuiltin' being (now) a loaded builtin to KSH,
it is also a program that appears twice in the current path
(lines 2 and 3). But it is *not* am undefined function
anywhere in any path (either 'PATH' or 'FPATH').

4) question:
Why does KSH list 'ourbuiltin' as an undefined function at all?

5) continuing (it gets even stranger); execute:
$ builtin -d ourbuiltin

6) confirm with:
$ whence -a builtin
output:
ourbuiltin is /usr/add-on/local/bin/ourbuiltin
ourbuiltin is /usr/extra/bin/ourbuiltin

7) analysis:
OK, KSH figured out now that 'ourbuiltin'
is not a function after all. OK, let's try some more.

8) execute:
$ builtin ourbuiltin

9) and execute:
$ whence -a ourbuiltin
output:
ourbuiltin is a shell builtin
ourbuiltin is /usr/add-on/local/bin/ourbuiltin
ourbuiltin is /usr/extra/bin/ourbuiltin
ourbuiltin is a tracked alias for /home/morano/ourbuiltin

10) question: Why does KSH now think that 'ourbuiltin' is a tracked
alias for anything (currently shown as being in my home directory)?
Curious, let us try ...

11) and:
$ cd rje
$ whence -a ourbuiltin
output
ourbuiltin is a shell builtin
ourbuiltin is /usr/add-on/local/bin/ourbuiltin
ourbuiltin is /usr/extra/bin/ourbuiltin
ourbuiltin is a tracked alias for /home/morano/rje/ourbuiltin

KSH is seems to think that 'ourbuiltin' is a tracked alias for whatever
present-working-directory (PWD) it is in. With more testing, KSH
thinks that this is a tracked alias within the ${PWD} whether or not
the ${PWD} or ':' is in any path (either 'PATH' or 'FPATH').

Why does KSH show a false function (first) and then a false tracked
alias (second) for loaded built-ins?

Is this somehow actually a feature? Or is this a bug (which is more
what it looks like)?

Thanks for any enlightenment.

Regards,

----
David A. Morano, PE, PhD
***@computer.org
Terrence J. Doyle
2015-05-19 16:52:47 UTC
Permalink
Sorry for the delayed response.

The fact that ourbuiltin shows up as an undefined function is further
evidence that your FPATH is wrong as I said in my response to your
earlier message, "core dump (crash) on KSH 2014-12-24". See
http://lists.research.att.com/pipermail/ast-developers/2015q2/004026.html if
you didn't get my response. Because ksh can't find a function called
ourbuiltin in any of the directories in your FPATH, it marks ourbuiltin
as an undefined function, so that it can be autoloaded later when the
file with the ourbuiltin function finally appears in one of your FPATH
directories.

Fix FPATH (preferably by unsetting it) in either your .profile or your
.kshrc, and some of these confusing messages will go away.

Terrence Doyle
Post by David A.D. Morano, PE, PhD
There is some (seemingly) very strange behavior with KSH 2014-12-24.
The behavior of the 'whence' KSH (built-in) command has often
been quite mysterious so I am not sure if this is new errant behavior
or possibly old errant behavior.
1) load a user-defined builtin-in (let us call it 'ourbuiltin')
$ whence -a ourbuiltin
ourbuiltin is a shell builtin
ourbuiltin is /usr/add-on/local/bin/ourbuiltin
ourbuiltin is /usr/extra/bin/ourbuiltin
ourbuiltin is an undefined function
The first three lines above seem correct. in addition to
the name 'ourbuiltin' being (now) a loaded builtin to KSH,
it is also a program that appears twice in the current path
(lines 2 and 3). But it is *not* am undefined function
anywhere in any path (either 'PATH' or 'FPATH').
Why does KSH list 'ourbuiltin' as an undefined function at all?
$ builtin -d ourbuiltin
$ whence -a builtin
ourbuiltin is /usr/add-on/local/bin/ourbuiltin
ourbuiltin is /usr/extra/bin/ourbuiltin
OK, KSH figured out now that 'ourbuiltin'
is not a function after all. OK, let's try some more.
$ builtin ourbuiltin
$ whence -a ourbuiltin
ourbuiltin is a shell builtin
ourbuiltin is /usr/add-on/local/bin/ourbuiltin
ourbuiltin is /usr/extra/bin/ourbuiltin
ourbuiltin is a tracked alias for /home/morano/ourbuiltin
10) question: Why does KSH now think that 'ourbuiltin' is a tracked
alias for anything (currently shown as being in my home directory)?
Curious, let us try ...
$ cd rje
$ whence -a ourbuiltin
output
ourbuiltin is a shell builtin
ourbuiltin is /usr/add-on/local/bin/ourbuiltin
ourbuiltin is /usr/extra/bin/ourbuiltin
ourbuiltin is a tracked alias for /home/morano/rje/ourbuiltin
KSH is seems to think that 'ourbuiltin' is a tracked alias for whatever
present-working-directory (PWD) it is in. With more testing, KSH
thinks that this is a tracked alias within the ${PWD} whether or not
the ${PWD} or ':' is in any path (either 'PATH' or 'FPATH').
Why does KSH show a false function (first) and then a false tracked
alias (second) for loaded built-ins?
Is this somehow actually a feature? Or is this a bug (which is more
what it looks like)?
Thanks for any enlightenment.
Regards,
----
David A. Morano, PE, PhD
_______________________________________________
ast-developers mailing list
http://lists.research.att.com/mailman/listinfo/ast-developers
Loading...