Given:
$ cat test.ksh
doit() {
doi1() {
echo doi1 "$@"
}
doi2() {
echo doi2 "$@"
}
doi1 a
doi2 b
}
doit
functions doit
typeset -f doit
Why do I get this output (doi2() and the last } are missing):
$ perl -e '$a=join("",<>);system("ksh","-c",$a)' test.ksh
doi1 a
doi2 b
doit() {
doi1() {
echo doi1 "$@"
}
{
echo doi2 "$@"
}
doit() {
doi1() {
echo doi1 "$@"
}
{
echo doi2 "$@"
}
and not this:
doi1 a
doi2 b
doit() {
doi1() {
echo doi1 "$@"
}
doi2() {
echo doi2 "$@"
}
doi1 a
doi2 b
}
doit() {
doi1() {
echo doi1 "$@"
}
doi2() {
echo doi2 "$@"
}
doi1 a
doi2 b
}
Is there any way I can tell ksh to leave the function names untouched and thus give me the full function definition?
$ ksh --version
version sh (AT&T Research) 93u+ 2012-08-01
ksh93 -c "$(cat test.ksh)"
. – Kusalananda Jul 18 '18 at 15:37ksh <test.ksh
has the same effect. It's not due to having multiple function definitions: the display is cut off after the end of the definition ofdoi1
, except for any other nested function definition. – Gilles 'SO- stop being evil' Jul 18 '18 at 20:03$0="myname"
in perl? – Ole Tange Jul 19 '18 at 00:02