From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26423 invoked by alias); 9 Oct 2014 07:46:39 -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: 19225 Received: (qmail 18473 invoked from network); 9 Oct 2014 07:46:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:message-id:subject:mime-version:content-type :content-transfer-encoding:content-disposition; bh=enDjdNf+nB0RLxwA05fr6itx/fHHK1PUUQMDS6Krm90=; b=xLqvTx/is7wO3f6UNYOAatGqxJiv0LflIahoiX+Zt5aWpUBD/BI2cmtu5bJ/iB6EdU 4nWqlEd1Jec/F84yn1P9GnFmK/9Ra3QB7uiUpcP/N92w446JpdV05PVPWDywb2Vm+38i WsFZv0dMBwp3Se3Mo2o0gaMQ2LFSbahnIUHWyOppF9ytbvIcg2WbD5uDg9ui8SabWoHh GCW0vxXe5DjyUTYoDCibkYjR4GaP8Gdt6VkVav3vqrkSBC2AewOzhmrUsmWr6JPnitB3 VOjVR+FcvjeofSduRaQlL5gLuscJmHMUfo1laZEEzwEdsg+/8YE8NP90wAdYpdGYimxP iO5w== X-Received: by 10.180.35.133 with SMTP id h5mr38078053wij.74.1412840477341; Thu, 09 Oct 2014 00:41:17 -0700 (PDT) Date: Thu, 9 Oct 2014 09:41:14 +0200 From: Enrico Maria Crisostomo To: zsh-users@zsh.org Message-ID: Subject: ZSH expansion of an evaluated parameter containing a pipe character (and differences between 4.x and 5.x) X-Mailer: Airmail (249) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi all, I=E2=80=99m trying to understand the rationale between a behavioural diff= erence between ZSH 4.3.17 (current in latest Debian stable) and ZSH 5.0.2= (current in latest OS X). =C2=A0I=E2=80=99m digging into the 'ZSH Shell = Manual=E2=80=99 but I haven=E2=80=99t found the (exact) answer to my ques= tion yet. The issue is the following. =C2=A0What I=E2=80=99m doing is storing into = a variable a command that will be executed later, the reason being the co= mmand depend on information only available at runtime. =C2=A0I=E2=80=99ve= detected a difference in behaviour between ZSH 4 and ZSH 5 when the afor= ementioned command contains a pipe. =C2=A0=46or the sake of argument, let= =E2=80=99s imagine the command is stored into =60EXAMPLE=5FCMD=60 and is = as simple as: =C2=A0 =C2=A0 EXAMPLE=5FCMD=3D=E2=80=9Cls -al =7C grep text=E2=80=9D If I eval this variable using ZSH 5, the result is the expected: =C2=A0 =C2=A0 =24 eval =24=7BEXAMPLE=5FCMD=7D that is: =C2=A0 * =60ls=60 is executed and passed =60-al=60 as a parameter. =C2=A0 * Its output is piped through =60grep=60, that is passed =60text=60= as a parameter. When I do the same thing in ZSH 4, the behaviour is different and leads t= o this failure: =C2=A0 =C2=A0 =23 eval =24=7BEXAMPLE=5FCMD=7D =C2=A0 =C2=A0 zsh: no matches found: ls -al =7C grep text However, if I quote =60EXAMPLE=5FCMD=60 in either version of the shell, t= he result is the same: =C2=A0 =C2=A0 =23 eval =E2=80=9C=24=7BEXAMPLE=5FCMD=7D=E2=80=9D =C2=A0 =C2=A0 drwxr-xr-x =C2=A02 root root =C2=A04096 Oct =C2=A06 21:02 t= ext According to my observations, it seems this issue is limited to the inter= pretation of the pipe in the command, since I=E2=80=99ve found no other d= ifferences between the behaviours of the two shell versions in this case.= To me, it came quite as a surprise to discover that quoting worked, since= I assumed that eval would receive 1 argument (the whole quoted string) a= nd that its behaviour wouldn=E2=80=99t change. =C2=A0Which leads me to th= ink that either ZSH 4 is performing an expansion I=E2=80=99m not aware of= affecting (at least) the meaning of =60=7C=60, or that this behaviour is= buggy. Now, the first question that I=E2=80=99m trying to answer is =E2=80=9CWhy= expansion is done like that=3F=E2=80=9D. =C2=A0The second one that comes= to mind is: what=E2=80=99s the rationale behind this change=3F =C2=A0Is = the behaviour of ZSH 4 considered buggy=3F More generally: could you share your thoughts about the =E2=80=9Cproper=E2= =80=9D/=E2=80=9Cbest=E2=80=9D/=E2=80=9Cput your favourite adjective here=22= way to handle this case in ZSH=3F Thank you very much for your insights. Cheers, -- =20 Enrico Maria Crisostomo