Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

how to capture and restore state of shell options



I thought this was meant to work:

    saved_options=$(set +o)
    .... do stuff ...
    eval "$saved_options"

But it doesn't. Inside command substitution, or even with output going to a pipe (though not with output going to a file), the `set +o` reports toggled options, including `set +o monitor` and `set +o zle`, which turn off job control and command-line editing after the "restoration".

The "not with output going to a file" part means this should work:

    saved_options=$(mktemp)
    set +o >$saved_options
    .... do stuff ...
    source $saved_options
    rm -f $saved_options

But is there a better way?

--
Mark J. Reed <markjreed@xxxxxxxxx>


Messages sorted by: Reverse Date, Date, Thread, Author