1

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
Ole Tange
  • 35,514

0 Answers0