Extract full function definitions

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












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






share are missing):

$ perl -e '$a=join("",<>);system("ksh","-c",$a)' test.ksh
doi1 a
doi2 b
doit() {
doi1()
echo doi1 "$@"


echo doi2 "$@"

doit()  









up vote
1
down vote

favorite









up vote
1
down vote

favorite











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






share 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








share|improve this question










share|improve this question




share|improve this question









asked Jul 18 at 15:16









Ole Tange

11.2k1342101




11.2k1342101











  • FWIW, you'll get the same behaviour with ksh93 -c "$(cat test.ksh)".
    – Kusalananda
    Jul 18 at 15:37










  • @Kusalananda Yes. That is an even simpler example.
    – Ole Tange
    Jul 18 at 15:41










  • Strange bug. It seems to be triggered by ksh not having a script name: ksh <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 of doi1, except for any other nested function definition.
    – Gilles
    Jul 18 at 20:03










  • Can I set a (fake) script name? Somewhat similar to $0="myname" in perl?
    – Ole Tange
    Jul 19 at 0:02
















  • FWIW, you'll get the same behaviour with ksh93 -c "$(cat test.ksh)".
    – Kusalananda
    Jul 18 at 15:37










  • @Kusalananda Yes. That is an even simpler example.
    – Ole Tange
    Jul 18 at 15:41










  • Strange bug. It seems to be triggered by ksh not having a script name: ksh <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 of doi1, except for any other nested function definition.
    – Gilles
    Jul 18 at 20:03










  • Can I set a (fake) script name? Somewhat similar to $0="myname" in perl?
    – Ole Tange
    Jul 19 at 0:02















FWIW, you'll get the same behaviour with ksh93 -c "$(cat test.ksh)".
– Kusalananda
Jul 18 at 15:37




FWIW, you'll get the same behaviour with ksh93 -c "$(cat test.ksh)".
– Kusalananda
Jul 18 at 15:37












@Kusalananda Yes. That is an even simpler example.
– Ole Tange
Jul 18 at 15:41




@Kusalananda Yes. That is an even simpler example.
– Ole Tange
Jul 18 at 15:41












Strange bug. It seems to be triggered by ksh not having a script name: ksh <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 of doi1, except for any other nested function definition.
– Gilles
Jul 18 at 20:03




Strange bug. It seems to be triggered by ksh not having a script name: ksh <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 of doi1, except for any other nested function definition.
– Gilles
Jul 18 at 20:03












Can I set a (fake) script name? Somewhat similar to $0="myname" in perl?
– Ole Tange
Jul 19 at 0:02




Can I set a (fake) script name? Somewhat similar to $0="myname" in perl?
– Ole Tange
Jul 19 at 0:02















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457031%2fextract-full-function-definitions%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457031%2fextract-full-function-definitions%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay