Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Zsh will not parse an autoload function when it has short loops
- X-seq: zsh-workers 36313
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- Subject: Re: Zsh will not parse an autoload function when it has short loops
- Date: Fri, 28 Aug 2015 08:43:20 +0200
- Cc: zsh workers <zsh-workers@xxxxxxx>
- 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==
- In-reply-to: <CAKc7PVD_zqcB3iWsU_6RzYEeOy8Kax8LFwE=sh36rAXVHgfo5Q@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVD_zqcB3iWsU_6RzYEeOy8Kax8LFwE=sh36rAXVHgfo5Q@mail.gmail.com>
On Fri, Aug 28, 2015 at 8:39 AM, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author