KornShell (ksh) SegFault
I have found the following script causes a segmentation fault and core in KornShell (ksh) on AIX. Can anyone explain why I get the following results?
doOutput(){
Echo "Something"
}
doOutput() >&1
OR
doOutput(){
Echo "Something"
}
echo `doOutput()`
doOutput(){
Echo "Something"
}
doOutput()
doOutput(){
Echo "Something"
}
doOutput
OR
doOu开发者_如何转开发tput(){
Echo "Something"
}
doOutput >&1
Calls to functions in shells such as ksh don't use parentheses. They are only used during function definition.
Correct:
doOutput(){
Echo "Something"
}
doOutput
If you call a function with parameters, you separate them using spaces (no parentheses):
doOutput(){
Echo "$1 and then $2"
}
doOutput go stop
Incorrect:
doOutput(){
Echo "Something"
}
doOutput()
Plus, why are you redirecting stdout to stdout (>&1
)?
You've found a bug in ksh, and only the authors thereof, or someone with access to the source, can explain it to you. Real ksh didn't used to be open source, but perhaps that's changed.
精彩评论