Martijn Dekker schreef op 27-02-16 om 04:44:
> That means it should be possible to do
> 
>         save_options=$(set +o)
> 
> then change some options, then later restore the shell options with
> 
>         eval "$save_options"

Hmm. "-o interactive" is killing that with an "interactive: bad option"
error.

Yet, misc.c contains this bit of code:

                        if ((i != (size_t)-1) && (set ? 1U : 0U) == Flag(i))
                                /*
                                 * Don't check the context if the flag
                                 * isn't changing - makes "set -o
interactive"
                                 * work if you're already interactive.
Needed
                                 * if the output of "set +o" is to be used.
                                 */
                                ;

And if I manually experiment with "set -o", then it works as the comment
above says. But there must be some kind of bug in there because evalling
the output of the patched "set +o" outputs the "interactive: bad option"
error.

$ eval "$(set +o)"
../build/mksh: set: interactive: bad option

Ah ha! I see now: the 'interactive' option is turned off in subshells
(including command substitutions), so the output of

    set +o

is not the same as that of

    (set +o)

Hmm. And the "monitor" (job control) option is also turned off in subshells.

This clearly needs more work. Perhaps those two options should simply be
blacklisted from "set +o" output? Thoughts?

- M.

Reply via email to