From: Peter Stephenson <Peter.Stephenson@csr.com>
To: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: Can we have an additional output option for setopt?
Date: Thu, 19 Jan 2012 10:04:12 +0000 [thread overview]
Message-ID: <20120119100412.24fd288e@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <CAHYJk3Tu8UsY5r3vnZ3P-R7hZOdheaBG2MLnQ+xLLeSUvF3Hbw@mail.gmail.com>
On Wed, 18 Jan 2012 22:08:43 +0100
Mikael Magnusson <mikachu@gmail.com> wrote:
> printf '%s\t%s\n' ${(kv)options}
Here's one way of getting setopt to do that (a bit more neatly).
setopt() {
if (( $# )); then
typeset -ga global_setopt_args
global_setopt_args=("$@")
trap 'builtin setopt "${(@)global_setopt_args}"' EXIT
else
local k
zmodload -i zsh/parameter
for k in ${(ok)options}; do
printf "%-20s\t%s\n" $k ${options[$k]}
done
fi
}
It's a little hairy because running setopt as a function is unnatural
owing to the fact that certain options (xtrace in particular) always
have function scope. Alternatively, just use a separate function.
showoptions() {
local k
zmodload -i zsh/parameter
for k in ${(ok)options}; do
printf "%-20s\t%s\n" $k ${options[$k]}
done
}
--
Peter Stephenson <pws@csr.com> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
next prev parent reply other threads:[~2012-01-19 10:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-18 20:20 Larry Schrof
2012-01-18 21:08 ` Mikael Magnusson
2012-01-19 10:04 ` Peter Stephenson [this message]
2012-01-19 19:28 ` Greg Klanderman
2012-01-19 17:41 ` Bart Schaefer
2012-01-19 18:37 ` Larry Schrof
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=20120119100412.24fd288e@pwslap01u.europe.root.pri \
--to=peter.stephenson@csr.com \
--cc=zsh-users@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).