This is a clarification of 
http://lists.research.att.com/pipermail/ast-users/2013q3/004041.html 
([ast-users] ksh93 More Problems with Functions)

A function is not found in FPATH if PATH ends in ":" and PWD=FPATH
"type" produces wrong output after "cd" if command was found before in "."
“type” sources the function definition file if it is executable unless the 
function is defined as typeset -fu
This behavior is irritating since "type" does not read the file if it is not 
executable. And I believe that the contents of the file should not be executed 
by type even if it is read to check the contents.

OS and ksh version:
cp003421 > cat /etc/SuSE-release
SUSE Linux Enterprise Desktop 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
cp003421 > Version AJM 93u+ 2012-08-01

Details:
cp003421> cat typesettest.sh
#!/bin/ksh

FPATH=~/utils

typeset -p FPATH
cd $FPATH
echo "Current dir: " $(pwd)

if [[ $1 = typeset ]]; then
  typeset -fu testfunc
  typeset -fu testfuncx
fi

echo "\ncall type twice to check if type sources the function"
type testfunc
type testfunc
type testfuncx
type testfuncx

echo "\ncalling testfunc"
testfunc f
echo "calling testfuncx"
testfuncx f

unset -f testfunc testfuncx

cd $HOME
echo "\nCurrent dir: " $(pwd)

if [[ $1 = typeset ]]; then
  typeset -fu testfunc
  typeset -fu testfuncx
fi

echo "\ncall type twice to check if type sources the function"
type testfunc
type testfunc
type testfuncx
type testfuncx

echo "\ncalling testfunc"
testfunc f
echo "calling testfuncx"
testfuncx f



cp003421> ls -la /ya/yae55/yae5511/utils/testfunc 
/ya/yae55/yae5511/utils/testfuncx
-rw-r----- 1 yae5511 yae55 233 Jul 18 12:50 /ya/yae55/yae5511/utils/testfunc
-rwxr-x--- 1 yae5511 yae55 235 Jul 18 12:50 /ya/yae55/yae5511/utils/testfuncx

cp003421> PATH=/usr/bin: ./typesettest.sh
typeset -x FPATH=/ya/yae55/yae5511/utils
Current dir:  /ya/yae55/yae5511/utils

call type twice to check if type sources the function
./typesettest.sh[15]: whence: testfunc: not found
./typesettest.sh[16]: whence: testfunc: not found
testfuncx is a tracked alias for /ya/yae55/yae5511/utils/testfuncx
testfuncx is a tracked alias for /ya/yae55/yae5511/utils/testfuncx

calling testfunc
./typesettest.sh[23]: testfunc: cannot execute [Permission denied]
calling testfuncx

testfuncx sourced

Current dir:  /ya/yae55/yae5511

call type twice to check if type sources the function
testfunc is an undefined function
testfunc is an undefined function

testfuncx sourced
testfuncx is a tracked alias for /ya/yae55/yae5511/testfuncx
testfuncx is a function

calling testfunc

testfunc sourced
Local function
calling testfuncx
Local function

cp003421> ls -la /ya/yae55/yae5511/testfuncx
ls: cannot access /ya/yae55/yae5511/testfuncx: No such file or directory


cp003421> PATH=/usr/bin: ./typesettest.sh typeset
typeset -x FPATH=/ya/yae55/yae5511/utils
Current dir:  /ya/yae55/yae5511/utils

call type twice to check if type sources the function
testfunc is an undefined function
testfunc is an undefined function
testfuncx is an undefined function
testfuncx is an undefined function

calling testfunc
./typesettest.sh: line 23: function: not found
calling testfuncx
./typesettest.sh: line 25: function: not found

[snip]


cp003421_home> PATH=/usr/bin
cp003421_home> FPATH=/ya/yae55/yae5511/utils
cp003421_home> type testfunc
testfunc is an undefined function
cp003421_home> type testfuncx

testfuncx sourced
testfuncx is an undefined function



Mit freundlichen Gruessen / Best Regards
Axel PHILIPP
MTU Aero Engines AG

--
MTU Aero Engines AG
Geschaeftsfuehrung/Board of Management: Egon W. Behle, Vorsitzender/CEO; Dr. 
Rainer Martens, Michael Schreyögg, Dr. Stefan Weingartner, Reiner Winkler
Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: Klaus 
Eberhardt
Sitz der Gesellschaft/Registered Office: Muenchen
Handelsregister/Commercial Register: Muenchen HRB 157206

Diese E-Mail sowie ihre Anhaenge enthalten MTU-eigene vertrauliche oder 
rechtlich geschuetzte Informationen.
Wenn Sie nicht der beabsichtigte Empfaenger sind, informieren Sie bitte den 
Absender und loeschen Sie diese
E-Mail sowie die Anhaenge. Das unbefugte Speichern, Kopieren oder Weiterleiten 
ist nicht gestattet.

This e-mail and any attached documents are proprietary to MTU, confidential or 
protected by law.
If you are not the intended recipient, please advise the sender and delete this 
message and its attachments.
Any unauthorised storing, copying or distribution is prohibited.
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users

Reply via email to