From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2679 invoked by alias); 4 Jun 2014 01:24:08 -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: 32692 Received: (qmail 20412 invoked from network); 4 Jun 2014 01:23:57 -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: <140603182344.ZM28117@torch.brasslantern.com> Date: Tue, 03 Jun 2014 18:23:44 -0700 In-reply-to: <538E5212.6000506@bbn.com> Comments: In reply to Richard Hansen "Re: 'emulate sh -c' and $0" (Jun 3, 6:54pm) 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, 6:54pm, Richard Hansen wrote: } } else if the function was not defined under an emulation mode but } we're currently running under an emulation mode: } 1. back up the current_option_state pointer } 2. set current_option_state to point to global_option_state } 3. call the function } 4. restore current_option_state The flaw in this model is that (1) there is no global option state object, only a local state object on the C call stack that represents the global state at the time the function was entered; and (2) even if there were a global state, pointing to that would still be wrong; what you want is to point to (i.e., overwrite the current global state with) the option state from one frame earlier in the call stack. Next you have the issue of the LOCAL_OPTIONS option, and what that means to your emulated state when that is not set in the frame from which you restored.