From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7403 invoked by alias); 23 Dec 2015 14:29:54 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21098 Received: (qmail 23134 invoked from network); 23 Dec 2015 14:29:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: vogt@linux.vnet.ibm.com X-IBM-RcptTo: zsh-users@zsh.org Date: Wed, 23 Dec 2015 15:19:14 +0100 From: Dominik Vogt To: zsh-users@zsh.org Subject: Re: emulate zsh *except* pushd related options Message-ID: <20151223141913.GA10364@linux.vnet.ibm.com> Reply-To: vogt@linux.vnet.ibm.com Mail-Followup-To: zsh-users@zsh.org References: <20151222083043.GA6457@linux.vnet.ibm.com> <151222205747.ZM29374@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151222205747.ZM29374@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15122314-0009-0000-0000-00000718A1DD On Tue, Dec 22, 2015 at 08:57:47PM -0800, Bart Schaefer wrote: > On Dec 22, 9:30am, Dominik Vogt wrote: > } > } Is there a (safe!) way to say "emulate zsh but don't touch certain options"? > > The "emulate" command accepts the same "-o optionn_name" (or "+o") as > shell startup, so you can do > > emulate -L zsh -o shwordsplit ... Unfortunately my zsh is too old for that. > For your specific use case, the current state of the pushd and cd options > can be enumerated this way: > > ${(Oa)${${(kv)options[(I)*pushd*|cd*|*cd]/off/+o}/on/-o}} > > That won't work in general because some options have "on" as a substring > of the option name. > > So if your autoloaded function begins with: > > emulate -L zsh -o shwordsplit \ > ${(Oa)${${(kv)options[(I)*pushd*|cd*|*cd]/off/+o}/on/-o}} > > you should get what you want. So I'll do something like this: PRESERVE_OPTS=($(setopt | grep "\(^cd\)\|\(cd$\)\|\(pushd\)")) emulate zsh setopt shwordsplit "$PRESERVE_OPTS[@]" I tried to get rid of the grep with parameter expansion but failed to understand the syntax. As far as I understand, this should do the job, but it doesn't: pat='^(*pushd|cd*|*cd)'; PRESERVED_OPTS=(${~$(setopt)//${~pat}/}) It deletes *all* words, not just the ones not matching (*pushd|cd*|*cd). (Actually the parentheses seem not to work as described for filename generation at all.) Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany