Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version;
        bh=n6yWE6viL3tBFvWB0j75okGMM02dUJjW4o+XHbCw2zk=;
        b=ujnJ+AcR9iofsZPPDex1wA1iE7hA4kGvIAvVp+Ga5QAq/85jJ62ATqkvzdcv9udVL2
         axubBVcFo/Y4ZoQmNmJJy99Rc0yOU0XrAJht70XukW71zKj1MgxVN28EsQhUB+XzXVjH
         /jgqPjmYG1DGfgdVtT30CNtiDh35OTCbnLeKn3btAo1jIyv6sCMnmtMkaENAo0H2J9c6
         3IZTOE07LMIZYZcKkCzxOlcFGffYCYeWXHfcEh0jYzeryXJZ5E/VVHj14FjjzQuQcdVK
         f6xv78VJaTtiWTDLg+eKli1FX8ZcBG5QpcS0GQl9ntrcJLg3tlRMyA08zdQ7UnFfU0ya
         aM5w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version;
        bh=n6yWE6viL3tBFvWB0j75okGMM02dUJjW4o+XHbCw2zk=;
        b=hLqgHs01z1BbxpAqfsjJ2JVExxDkT2MpN3u508f5p3MApV0ArtB13JPxQYISNfTXM9
         L6WxotdCVIOakWHBXMoC1+jebtK8JhvSdLCfPtQT5E7Y/5IPcjBiGT2R/JdXxIQ7lXLd
         E3rIEBJ6rOoYRbFTDd7oQKuZpZLLAQfPfMCOXDS3wpQ5wwsnCdTx/hSYxILIACqQNC7a
         RSObnfXNuFIi3eLJL3XvbPFuvzGsKX9UOLYnF1R5P835cTANwV2zs6Nkkh1MeZHcJbV6
         pjJaHC26ZGK/KQ46nmouiMeHgRkA3+V7zX8adxVjfX3iHZmC25f1qp6Gv6cAg/G2Fhws
         2uOg==
X-Gm-Message-State: ALyK8tKmOvfVGoZrVsrYLc1qnPEW9sItfCMBmE6Bz7+cibeAbJTv1zlhYksp/mE3HsFu3w==
X-Received: by 10.98.50.135 with SMTP id y129mr9591143pfy.62.1465665237940;
        Sat, 11 Jun 2016 10:13:57 -0700 (PDT)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160611101412.ZM12850@torch.brasslantern.com>
Date: Sat, 11 Jun 2016 10:14:12 -0700
In-Reply-To: <CAKc7PVBSCgG4Y87L_PzCEWDk=-cQLFmLxwps_rfvUUuhA-Np+w@mail.gmail.com>
Comments: In reply to Sebastian Gniazdowski <sgniazdowski@gmail.com>
        "SH_GLOB influence on a script and on an autoload function" (Jun 11,  7:11am)
References: <CAKc7PVBSCgG4Y87L_PzCEWDk=-cQLFmLxwps_rfvUUuhA-Np+w@mail.gmail.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: SH_GLOB influence on a script and on an autoload function
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 38660

On Jun 11,  7:11am, Sebastian Gniazdowski wrote:
}
} Below is a simple script (save to file rtest1) that works well despite
} SH_GLOB should or could stop the pattern from parsing. The same
} doesn't work for autoload.

A script is executed line by line as it is parsed.  An autoloaded function
is fully parsed first, then executed.  Hence in the script, the "emulate"
command resets the parsing rules before the expression is encountered.

This is one of the drawbacks to attempting to accurately emulate parsing
rules that are inherently contradictory.

} setopt shglob
} FPATH=$FPATH:`pwd`
} autoload rtest1
} rtest1
} 
} Probably no workaround for this?

In "recent" zsh (since roughly 2009) you can do this:

    emulate zsh -c 'autoload rtest1'

but of course you have to know a priori what emulation mode the function
is going to want.

