David A.D. Morano, PE, PhD
2015-04-28 15:51:56 UTC
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
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