From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18783 invoked by alias); 9 Jan 2013 07:36:01 -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: 17543 Received: (qmail 22119 invoked from network); 9 Jan 2013 07:35:46 -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=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.210.173 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=cjeZCnlzcuUyWls3Q2Ezdo24CzvKCsncEaej8Q9f7iY=; b=jhozta3IhdZKV4e5CfnIzRaFTE7mscsd7pXSRE0MmMNEKjgzGrGrzWhkaCc+/jw0oo yXR+CB9YCQavgfbO7VJtY5AWnm8i66vSWam8jfOC4FHBGoKRFbcJv45Ff1ICw3VkOlj4 2mc/1GgEc8QzDo1f4AV4l81TCl2KvVypnaeuPdbaE1UmPYv5VL356NCiLXXiQOIfal+z daM/qLNQHUU8cScIRCKS5arvHvEVLpvlZVH9g4sQt/deEDGSc4y4aHNek47GDSyJAyFL bCOlVrVTeVqdg6ywcYCUft/B/R2BKD5IwUXJLbTtbuzhWmXS+nv9bMlXhooqAP0RK7QE CkYQ== MIME-Version: 1.0 Date: Wed, 9 Jan 2013 12:00:34 +0530 Message-ID: Subject: array matching: inconsistent behaviour ? From: rahul To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=bcaec5101bfd1f684304d2d53321 --bcaec5101bfd1f684304d2d53321 Content-Type: text/plain; charset=UTF-8 Or am I doing the matching wrong? I am storing file names in an array. Later I match filenames against those in the array for various purposes. The filenames contain spaces and in this unfortunate case round brackets. File names with brackets are failing the match. FOO=() x="a file" y="a(file)b" FOO+=($x) FOO+=($y) print $FOO[(i)$x] print $FOO[(i)$y] # Now I found, that if i quote the string while matching then the comma file matches, but now the space file fails. print $FOO[(i)$x:q] print $FOO[(i)$y:q] If I escape/quote the string when adding to the array then again one of the two matches fails. In any case, I cannot escape the names when inserting into the array, as often double quoting/escaping happens when methods are called repeatedly, and external commands give errors if they get quoted filenames. I only quote the string finally if I am "eval"ing a command. I'd like to know if I am doing this wrong, is there a consistent way of matching the string inside the array. -- rahul --bcaec5101bfd1f684304d2d53321--