ksh93 / ksh

ksh 93u+m: KornShell lives! | Latest release: https://github.com/ksh93/ksh/releases
Eclipse Public License 2.0
192 stars 32 forks source link

document shell option behavior wrt functions #751

Closed adavies42 closed 5 months ago

adavies42 commented 6 months ago

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?

hlangeveld commented 5 months ago

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.

adavies42 commented 5 months ago

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.

McDutchie commented 5 months ago

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.