From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3/2) with ESMTP id HAA12153 for ; Wed, 3 Jul 1996 07:36:28 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id RAA03925; Tue, 2 Jul 1996 17:30:50 -0400 (EDT) Resent-Date: Tue, 2 Jul 1996 17:30:50 -0400 (EDT) From: "Bart Schaefer" Message-Id: <960702143114.ZM5210@candle.brasslantern.com> Date: Tue, 2 Jul 1996 14:31:10 -0700 In-Reply-To: Anthony Heading "Re: Tag functions with shell options?" (Jul 2, 8:53pm) References: <199607021953.UAA05899@et-sun4.uk.jpmorgan.com> Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.607 07jun96) To: Anthony Heading Subject: Re: Tag functions with shell options? Cc: zsh-workers@math.gatech.edu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"vVRYs2.0.Fz.9KPsn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1515 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Jul 2, 8:53pm, Anthony Heading wrote: } Subject: Re: Tag functions with shell options? } } The lack of context was sort-of deliberate, since I } suspected any interest would be in the wider picture, rather than my } particular petty problems. It seemed simply an example of something } it would be nice to support elegantly. This introduces a whole class of problems, which is most obvious in the case when you *do not* know the names of the functions that should have their local options (or whatever) changed. In that case you almost end up needing something like Perl's "package", so that you can do e.g.: package admin . /etc/profile for f in $(whence -FP admin) do typeset -fo ${f}=(shwordsplit globassign bsdecho nobgnice);; done Where I'm assuming a slew of new features: 1. `package foo' groups all functions, aliases, etc. in the package named `foo' until the next `package' is executed 2. `whence -F' lists the names (but NOT definitions) of functions [Aside: Why doesn't `typeset +f' do that already?] 3. `whence -P foo' lists from the package `foo' 4. `typeset -o' is equivalent to `setopt' (and `+o' to `unsetopt') 5. `typeset -fo foo=(options...)' sets local options for `foo', as if `foo' began with `setopt localoptions options...' 6. Zoltan's (or was it Zefram's?) change to make `setopt nofoo' be equivalent to `unsetopt foo' } > it seems to me that a much simpler implementation of sws_fn is: } [wrapping the function, and then aliasing the wrapper to the original] } } > The only drawback to this is that other functions that may already have } > been defined won't see the alias -- but presumably those functions will } > themselves be given the sws_fn treatment, so it's moot. } } Hmm. Don't understand the first point, but I'll experiment. Example: yfn () { echo Y } zfn () { echo Z } xfn1 () { yfn } alias yfn=zfn xfn2 () { yfn } Now: zsh% xfn1 Y zsh% xfn2 Z Because the alias for yfn was introduced *after* xfn1 was defined, xfn1 still references the "real" yfn, rather than the alias. The presumption is that if you're going to use sws_fn yfn Then you are also going to use sws_fn xfn1 sws_fn xfn2 So that it doesn't matter what "yfn" means inside of xfn*. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.nbn.com/people/lantern New male in /home/schaefer: >N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"