From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23053 invoked by alias); 25 Nov 2015 09:39:46 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20988 Received: (qmail 16299 invoked from network); 25 Nov 2015 09:39:45 -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=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vnoss.org; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=O/GK4ofkSOZczH7vWMIp2E12szQD6VEKaWXehFRkl4Q=; b=N+HlQgmBQd1/6oI3DXdmHPOXGHJQOQctDFwgJiNoG6hZUV6Z/xiGDzA9d0YemHqQ71 /B7VhAf+3XjNhiYRSdc0z2N8RyjTwVNAPUKFd6M/2SpYZVzN2gqfTzidPyRsbBCVWVfX cx4zMQp1dNPSooLpdRSgQ2s5CazBkSjcE1Lvs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=O/GK4ofkSOZczH7vWMIp2E12szQD6VEKaWXehFRkl4Q=; b=I5IXUpHds7zal7Fll1TwNIfzZ67NmzDeUKa8p8jJdID2x1KO/+hfvTouv0uchQGQEF 6zYMe2aCdVgQS+bKury6A1WQdAQ5BUl0fup9AdjVci9Pk0bWcWophArAJxtIVzbJNWEs 8hGcmFsOSlEHtctJznXOztzMnROSC83jqj8KhMBnATR7+0d5jO7OYt0ZbyHKcoOXAcJx SpXTRQLs6vL0A5fBbnjs6Zqo2RRui187VSbMskMuSnRuyqOBipGtq00ufXfSohK1/dX5 dQlg1NABDvRsNFX62aZPRmoO+Yk+mOYUn9IW8aEsQLQPec1WsVhXJVUfzuCT2XYq0XR5 GtWw== X-Gm-Message-State: ALoCoQko6ajNrIRj4evf5XUYK7z8psaw6cxioXBp7KGA25SzZzmqJSclZsQCoA/v1YWbQyT3w8nV MIME-Version: 1.0 X-Received: by 10.60.69.104 with SMTP id d8mr24576235oeu.52.1448444383449; Wed, 25 Nov 2015 01:39:43 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Nov 2015 16:39:43 +0700 Message-ID: Subject: Re: [Zsh bug] function define bug From: =?UTF-8?B?TmfDtCBIdXk=?= To: Cuong Manh Le Cc: Matthew Martin , Zsh Users Content-Type: multipart/alternative; boundary=001a11330670f4032b05255a3c2d --001a11330670f4032b05255a3c2d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Dear Cuong, 2015-11-25 16:20 GMT+07:00 Cuong Manh Le : > Hi Huy, > > It's a good point, but in the user perspective, turn off `multifuncdef` i= s > not much useful: > > $ unsetopt multifuncdef > $ echo 1 | grep foobar(){ echo 1; } > zsh: parse error near `()' > > You still stuck and can not use `grep`. > > The right way to use it from the beginning is quote the grep string > pattern if it contains any shell meta characters. > > Also in zsh documentation > http://zsh.sourceforge.net/Doc/Release/Options.html#index-MULTIFUNCDEF , > it said that: > > Multiple function definitions are not often used and can cause obscure >> errors. > > > Maybe we should add an example to that section. > > Best. > > > > On Wed, Nov 25, 2015 at 4:03 PM, Ng=C3=B4 Huy wro= te: > >> Dear Cuong, >> >> 2015-11-25 15:49 GMT+07:00 Cuong Manh Le : >> >>> Hi Severus, >>> >>> Can you give a demo? >>> >>> You can turn off `mult=C3=AC_func_def` but you can always do multiple >>> function definition with reserved word `function` >>> >>> Best. >>> >>> >>> On Wed, Nov 25, 2015 at 11:20 AM, Ng=C3=B4 Huy = wrote: >>> >>>> Dear Matthew >>>> >>>> 2015-11-25 11:06 GMT+07:00 Matthew Martin : >>>> >>>> > On Tue, Nov 24, 2015 at 9:46 PM, Ng=C3=B4 Huy >>>> wrote: >>>> > > Dear folks, >>>> > > >>>> > > I found the problem in zsh define function. Demo >>>> > > >>>> > > ls test() { echo "Bug !!!"} && ls && test >>>> > > >>>> > > it will print >>>> > > >>>> > > Bug !!! >>>> > > Bug !!! >>>> > >>>> > >>>> > That's expected behaviour. Since MULTI_FUNC_DEF is set by default in >>>> zsh >>>> > mode, both ls and test are being defined as functions with the body >>>> > echo "Bug !!!". >>>> > >>>> > % func1 func2 () { echo This is "$0"; } >>>> > % func1; func2 >>>> > This is func1 >>>> > This is func2 >>>> > % which func{1,2} >>>> > func1 () { >>>> > echo This is "$0" >>>> > } >>>> > func2 () { >>>> > echo This is "$0" >>>> > } >>>> > % unsetopt MULTI_FUNC_DEF >>>> > % func1 func2 () { echo This is "$0"; } >>>> > zsh: parse error near `()' >>>> > >>>> >>>> I know this behavior likes advanced programming language but >>>> mult=C3=AC_func_def >>>> should be turned off by default, it leads to risky problem when someon= e >>>> searchs as grep, ls malicious strings without quote >>>> >>>> >>>> Kind regards, >>>> Severus >>>> >>> >>> this's just example: cat file | grep foobar(){ rm -rf *} >> grep wil execute rest of body >> >> Kind regards, >> Severus >> > > I don't see any case we should use multiple function definition. We also can not cover all problems with this behavior. I think we should disable it :) Kind regards, Severus --001a11330670f4032b05255a3c2d--