zsh-workers
 help / color / mirror / code / Atom feed
From: Alexandre Rames <alexandre.rames@uop.re>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Issue trying to save and restore options
Date: Wed, 23 May 2018 08:54:09 -0700	[thread overview]
Message-ID: <CALN_81bMvoBiGLikyZDrjVbO0Hxr43-WxtLr7=e7tpJ6z2n4cA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 959 bytes --]

Hello,

As part of a script, I was trying to save and restore options in a
shell-agnostic way. The goal is to write

```
# Save options.
set -x
# Modify other options.
# Do stuff.
# Restore options
```

Googling, I came across this stack overflow answer
<https://unix.stackexchange.com/questions/310957/how-to-undo-a-set-x/310963?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa>,
suggesting the use of `set +o`.
However this gives me unexpected results

% zsh --no-globalrcs --no-rcs
username% zsh --version
zsh 5.5.1 (x86_64-apple-darwin17.5.0)
username% set +o
set +o noaliases
# More option lines. See full log attached.
set -o zle
username% OPTS=$(set +o)
# Hitting Ctrl-C works as expected
username%
username%
username% eval "$OPTS"
# Hitting Ctrl-C now does not behave as expected
username% ^C^C^C

The same thing works in `bash` though.
Does someone know if that is expected to work? Is that a known issue with
zsh?

Alexandre

[-- Attachment #1.2: Type: text/html, Size: 1835 bytes --]

[-- Attachment #2: log --]
[-- Type: application/octet-stream, Size: 3684 bytes --]

% zsh --no-globalrcs --no-rcs
username% zsh --version
zsh 5.5.1 (x86_64-apple-darwin17.5.0)
username% set +o
set +o noaliases
set +o aliasfuncdef
set +o allexport
set +o noalwayslastprompt
set +o alwaystoend
set +o appendcreate
set +o noappendhistory
set +o autocd
set +o autocontinue
set +o noautolist
set +o noautomenu
set +o autonamedirs
set +o noautoparamkeys
set +o noautoparamslash
set +o autopushd
set +o noautoremoveslash
set +o autoresume
set +o nobadpattern
set +o nobanghist
set +o nobareglobqual
set +o bashautolist
set +o bashrematch
set +o nobeep
set +o nobgnice
set +o braceccl
set +o bsdecho
set +o nocaseglob
set +o nocasematch
set +o cbases
set +o cdablevars
set +o chasedots
set +o chaselinks
set +o nocheckjobs
set +o nocheckrunningjobs
set +o noclobber
set +o combiningchars
set +o completealiases
set +o completeinword
set +o continueonerror
set +o correct
set +o correctall
set +o cprecedences
set +o cshjunkiehistory
set +o cshjunkieloops
set +o cshjunkiequotes
set +o cshnullcmd
set +o cshnullglob
set +o nodebugbeforecmd
set +o dvorak
set +o emacs
set +o noequals
set +o errexit
set +o errreturn
set +o noevallineno
set +o noexec
set +o extendedglob
set +o extendedhistory
set +o noflowcontrol
set +o forcefloat
set +o nofunctionargzero
set +o noglob
set +o noglobalexport
set -o noglobalrcs
set +o globassign
set +o globcomplete
set +o globdots
set +o globstarshort
set +o globsubst
set +o nohashcmds
set +o nohashdirs
set +o hashexecutablesonly
set +o nohashlistall
set +o histallowclobber
set +o nohistbeep
set +o histexpiredupsfirst
set +o histfcntllock
set +o histfindnodups
set +o histignorealldups
set +o histignoredups
set +o histignorespace
set +o histlexwords
set +o histnofunctions
set +o histnostore
set +o histreduceblanks
set +o nohistsavebycopy
set +o histsavenodups
set +o histsubstpattern
set +o histverify
set +o nohup
set +o ignorebraces
set +o ignoreclosebraces
set +o ignoreeof
set +o incappendhistory
set +o incappendhistorytime
set -o interactive
set +o interactivecomments
set +o ksharrays
set +o kshautoload
set +o kshglob
set +o kshoptionprint
set +o kshtypeset
set +o kshzerosubscript
set +o nolistambiguous
set +o nolistbeep
set +o listpacked
set +o listrowsfirst
set +o nolisttypes
set +o localloops
set +o localoptions
set +o localpatterns
set +o localtraps
set +o login
set +o longlistjobs
set +o magicequalsubst
set +o mailwarning
set +o markdirs
set +o menucomplete
set -o monitor
set +o nomultibyte
set +o nomultifuncdef
set +o nomultios
set +o nonomatch
set +o nonotify
set +o nullglob
set +o numericglobsort
set +o octalzeroes
set +o overstrike
set +o pathdirs
set +o pathscript
set +o pipefail
set +o posixaliases
set +o posixargzero
set +o posixbuiltins
set +o posixcd
set +o posixidentifiers
set +o posixjobs
set +o posixstrings
set +o posixtraps
set +o printeightbit
set +o printexitvalue
set +o privileged
set +o promptbang
set +o nopromptcr
set +o nopromptpercent
set +o nopromptsp
set +o promptsubst
set +o pushdignoredups
set +o pushdminus
set +o pushdsilent
set +o pushdtohome
set +o rcexpandparam
set +o rcquotes
set -o norcs
set +o recexact
set +o rematchpcre
set +o restricted
set +o rmstarsilent
set +o rmstarwait
set +o sharehistory
set +o shfileexpansion
set +o shglob
set -o shinstdin
set +o shnullcmd
set +o shoptionletters
set +o noshortloops
set +o shwordsplit
set +o singlecommand
set +o singlelinezle
set +o sourcetrace
set +o sunkeyboardhack
set +o transientrprompt
set +o trapsasync
set +o typesetsilent
set +o nounset
set +o verbose
set +o vi
set +o warncreateglobal
set +o warnnestedvar
set +o xtrace
set -o zle
username% OPTS=$(set +o)
username%
username%
username% eval "$OPTS"
username% ^C^C^C

             reply	other threads:[~2018-05-23 18:21 UTC|newest]

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

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_81bMvoBiGLikyZDrjVbO0Hxr43-WxtLr7=e7tpJ6z2n4cA@mail.gmail.com' \
    --to=alexandre.rames@uop.re \
    --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).