From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23879 invoked by alias); 25 Nov 2015 09:04:26 -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: 20985 Received: (qmail 29360 invoked from network); 25 Nov 2015 09:04:25 -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=tixwHrg2ZtnmG3tn1aj6vI+M88MZcl1kn456lOBCJ78=; b=iH7pY5oOhFNNRvnod2iiQoMW1Af5DoifzcV/9u2itGTJQHF6uD8ayMvMnKjt2O+pwL QhZI46Zm3pO71uCZcipS+rJfjTQsWbhPlzwt/iQiK34FsbMiF8RhKXXvTw4o0YbXrg/T KtJcjBQSXI0JgbQEjParHLPN4ppOVbXuJtaC4= 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=tixwHrg2ZtnmG3tn1aj6vI+M88MZcl1kn456lOBCJ78=; b=VO5hnus+TqGpmyIY+PR2xcqR3pmf6SfErWawp2viW1KMPTqV/pvVgkZmsPtmFDQks0 Nkn6Ua7jtyMpioyQEZ7NdwXRmRyd2w1PAXGUb5QlsSCFL63a2nM6WaBB9b+IP2NSmt5+ vzLey0bMwz7jQUbzgO6CwDy27NIuAX0ge6yNLqSspno31YOKXPTc8sYvIAlFAUwn+7RT 65ga5r+pWkuKMVChDlBlV1U6OA7fAylv9SkJ7cBH+EQugv6jroklNPzGmuSj9axodfPX WmkEXaE0vnfcDuBx1QnavLYtjzEjAcIXKnXnUf2/KeJM/mFJ+WRpvIVvtt9ZoVETaCtL Bqhw== X-Gm-Message-State: ALoCoQnfK+67gjXLB0m0elt5EcgK78dTkwA6lCqmAqJZ9Q2JyM82HaMif1+YJmjmWvkt4xz8r0Re MIME-Version: 1.0 X-Received: by 10.60.69.104 with SMTP id d8mr24496271oeu.52.1448442264717; Wed, 25 Nov 2015 01:04:24 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Nov 2015 16:04:24 +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=001a11330670aaab79052559be17 --001a11330670aaab79052559be17 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Dear all, 2015-11-25 16:03 GMT+07:00 Ng=C3=B4 Huy : > 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 fu= nction >> definition with reserved word `function` >> >> Best. >> >> >> On Wed, Nov 25, 2015 at 11:20 AM, Ng=C3=B4 Huy w= rote: >> >>> 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 someone >>> 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 reason for multiple functions have same body but different name. Let's me know if I'm wrong :) Kind regards, Severus --001a11330670aaab79052559be17--