From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14617 invoked by alias); 28 Aug 2015 06:43:24 -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: 36313 Received: (qmail 17202 invoked from network); 28 Aug 2015 06:43:24 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Jam41rshta+NIVPXQz0TELLiBe7xGEYYQ+RiEuq/nQY=; b=FnGYTuzv0p4+e64Dl8rw9aATv5Tg8Tp7Ka2QnOfzCYhYX+pImAF1QOGlZBo/S411w5 X0ltsoIK09Kh1GbFkUF17yDod31hDScg/EXagm8a5taQ50/zQLn5OLyrkbjuMvJadLDp RX/1QiLU7TX5mjURye1VgC+oqjn/ISWAM96M0bSG0J8fXJuXTFOsVqjjnfAfHIQIkJ4V RckKcJCyDPXR9WQN2rikXCoURTGS9E9W+y3C7d1TvybAi5wrj4WqY629K+lxzFctEyDn u9B5n1FU+bLFce7ffYqpI3npyvMvWg+t25STUg04U8ubQ/V2TM5nWDXn3IBg5enZIpdw i9dQ== MIME-Version: 1.0 X-Received: by 10.140.129.22 with SMTP id 22mr14018449qhb.16.1440744200478; Thu, 27 Aug 2015 23:43:20 -0700 (PDT) In-Reply-To: References: Date: Fri, 28 Aug 2015 08:43:20 +0200 Message-ID: Subject: Re: Zsh will not parse an autoload function when it has short loops From: Mikael Magnusson To: Sebastian Gniazdowski Cc: zsh workers Content-Type: text/plain; charset=UTF-8 On Fri, Aug 28, 2015 at 8:39 AM, Sebastian Gniazdowski wrote: > Hello > > I've created autoload function "bug" in /usr/share/zsh/.../functions, and > when run, it gives: > > bug:9: parse error near `list[$i]' > > Adding echo's to the file and changing various things revealed no reaction. > This means that the file isn't actually run by zsh - apparently the message > comes from some initial parsing stage. > > Here is the file: > > emulate -L zsh > > setopt localoptions typesetsilent localtraps extendedglob shortloops > > while (( 1 )); do > # No influence, the code isn't run at all > # typeset -a VLIST_NONSELECTABLE_ELEMENTS > if [ ! -z "$VLIST_SEARCH_BUFFER" ]; then > [ "$#VLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && for i > ("${(nO)VLIST_NONSELECTABLE_ELEMENTS[@]}") list[$i]=() > fi > > done This is expected, the shortloops option affects parsing of files. As you noticed the code is not run, only parsed, so therefore the setopt shortloops inside the function has no effect, but you use shortloops syntax which means it has to be on when you parse it. Long story short: don't use shortloops syntax in portable code. -- Mikael Magnusson