From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10811 invoked by alias); 4 Jun 2014 01:10:26 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32691 Received: (qmail 16618 invoked from network); 4 Jun 2014 01:10:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140603181014.ZM28105@torch.brasslantern.com> Date: Tue, 03 Jun 2014 18:10:14 -0700 In-reply-to: Comments: In reply to Bart Schaefer "Re: 'emulate sh -c' and $0" (Jun 3, 5:03pm) References: <5387BD0D.8090202@bbn.com> <140529204533.ZM5362@torch.brasslantern.com> <5388461D.8060203@bbn.com> <140530100050.ZM18382@torch.brasslantern.com> <5388F4C3.6070801@bbn.com> <140530221301.ZM31798@torch.brasslantern.com> <538E2CDD.7070106@bbn.com> <538E5212.6000506@bbn.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: 'emulate sh -c' and $0 MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jun 3, 5:03pm, Bart Schaefer wrote: } } On Jun 3, 2014 3:54 PM, "Richard Hansen" wrote: } > } > I was thinking more along the lines of temporarily } > restoring the top-level (non-emulated) option state when calling a } > function that was not defined inside of 'emulate -c'. (Maybe } > there's not a significant implementation difference between what I'm } > thinking and assigning sticky options to all functions.) } } Implementation aside, operationally this still violates dynamic scoping. } It means for example that the completion system can't set extendedglob on } entry and be sure it remains in effect throughout any helper functions it } calls. OK, that's not quite true. What you're suggesting is not that the called function has made the global options sticky, rather that if the calling function has sticky options, it automatically reverts them upon making a nested call. So that would only mess up completion if somebody did "emulate zsh -c compinit" to load it. That still prevents the calling function from intentionally propagating a particular set of options down to the called function, which I think is the more common use case (certainly so far it has been the *only* use case, though that may just be because no other is possible). And as I suspected "reverts them" currently involves completing the C fuction scope of doshfunc(), though that could be disentangled with a bit of effort.