ksh93/ksh

document shell option behavior wrt functions

adavies42 opened this issue · 3 comments

It's a long-standing behavior of ksh that set -e and set -x need to be repeated at the beginning of function functions (but not () functions) even if they're active in the main script.

Is it actually documented anywhere? Are there any other shell options that don't inherit into functions and/or differ between the two types of functions?

I recall that the AST team always tried to preserve existing behaviour for established syntax. For that reason, any new behaviour was only enabled in the new function name { ... syntax.

To be clear, what I'm suggesting is an addition to src/cmd/ksh93/sh.1, probably to the Functions section, documenting how set -o options behave wrt both types of functions.

Thanks for the heads-up on this omission, @adavies42. I've read the code for executing function keyword syntax functions and errexit and xtrace are the only two options that are turned off within such a function.