In ksh93 this barfs:
source foo.ksh
foo die
when foo.ksh contains just:
foo() {
echo Foo!
if [[ "$1" = "die" ]]; then
unset -f foo
fi
}
in bash, it works. How can a function unset itself in ksh?
In ksh93 this barfs:
source foo.ksh
foo die
when foo.ksh contains just:
foo() {
echo Foo!
if [[ "$1" = "die" ]]; then
unset -f foo
fi
}
in bash, it works. How can a function unset itself in ksh?
The same works in ksh
too. Consider foo.ksh
is :
foo()
{
echo "Bar"
if [ "$1" = "die" ]
then
unset -f foo
fi
}
Consider main.ksh
is :
source foo.ksh
foo die
foo # you haven't checked if the function is unset or not
Gives you :
bar --> first call
main.ksh[10]: foo: not found [No such file or directory] --> second call
Check it [ here ].