zsh-workers
 help / color / mirror / code / Atom feed
From: Alexandre Rames <alexandre@br-family.net>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org
Subject: Re: Issue trying to save and restore options
Date: Wed, 6 Jun 2018 11:27:07 -0700	[thread overview]
Message-ID: <CALN_81ZVq6JCEWytHvTH24wr9WQv5riDgvE0F3_g0B7FfL2oow@mail.gmail.com> (raw)
In-Reply-To: <1527100273.2173650.1382445048.53E74E5C@webmail.messagingengine.com>

[-- Attachment #1: Type: text/plain, Size: 1152 bytes --]

Sorry for the late reply.

Thanks for the help Daniel. Using redirection indeed works.

Here is what I used, in case it is useful to others:

OPTS_BACKUP=$(mktemp)
set +o > "$OPTS_BACKUP"
set -x

# More stuff

set +vx
RESTORE_STATE=$(cat "$OPTS_BACKUP")
eval "$RESTORE_STATE"

On Wed, May 23, 2018 at 11:31 AM Daniel Shahaf <d.s@daniel.shahaf.name>
wrote:

> Alexandre Rames wrote on Wed, 23 May 2018 08:54 -0700:
> > username% OPTS=$(set +o)
>
> The 'set' runs inside a subshell so it sees different options:
>
> [[[
> % set +o >1
> % printf '%s' "$(set +o)" >2
> % diff 1 2
> 116c116
> < set -o monitor
> ---
> > set +o monitor
> 177c177
> < set -o zle
> ---
> > set +o zle
> ]]]
>
> (The 'zle' option controls whether the line editor is enabled.)
>
> So, you could try capturing the output of 'set +o' using redirections
> rather than command substitutions; that should work and remain shell-
> agnostic.  (If you want a shell-specific solutions there are other ways,
> e.g., check $ZSH_VERSION and then use ${(kv)options} to save the
> values.)
>
> As to whether the behaviour of +o in a subshell should be changed, I'll
> leave that for others.
>

      reply	other threads:[~2018-06-06 20:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 15:54 Alexandre Rames
2018-05-23 18:31 ` Daniel Shahaf
2018-06-06 18:27   ` Alexandre Rames [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALN_81ZVq6JCEWytHvTH24wr9WQv5riDgvE0F3_g0B7FfL2oow@mail.gmail.com \
    --to=alexandre@br-family.net \
    --cc=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).