From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19857 invoked by alias); 9 Jan 2013 09:51:02 -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: 17545 Received: (qmail 23516 invoked from network); 9 Jan 2013 09:51:01 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) X-AuditID: cbfec7f4-b7f6d6d000001620-bc-50ed3b279977 Date: Wed, 09 Jan 2013 09:40:54 +0000 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: array matching: inconsistent behaviour ? Message-id: <20130109094054.021cbaa6@pwslap01u.europe.root.pri> In-reply-to: References: Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42I5/e/4NV1167cBBrMvSVnsOLmS0YHRY9XB D0wBjFFcNimpOZllqUX6dglcGdcmL2YuaGGveHHyFlsD417WLkZODgkBE4mvX7YyQthiEhfu rWfrYuTiEBJYyiix/8BSdiiHSeLHhyNMIFUsAqoSW1e/A+tgEzCUmLppNpgtIiAqsXzFZnYQ W1jAVGLq8+tgNq+AvcTEAw/YQGxOgWCJqW0fWEBsIYEAiWMr/4L18gvoS1z9+4kJ4gp7iZlX zjBC9ApK/Jh8D6yeWUBLYvO2JlYIW15i85q3zBMYBWYhKZuFpGwWkrIFjMyrGEVTS5MLipPS cw31ihNzi0vz0vWS83M3MUKC8MsOxsXHrA4xCnAwKvHwWs58EyDEmlhWXJl7iFGCg1lJhPei 6dsAId6UxMqq1KL8+KLSnNTiQ4xMHJxSDYxMd26Kv0/9Yub+2uTZwVDOYKtHdyZvvCrXu/FU 6w2VhbWhDbMVDF5wX/X/v+KEEr9HvavHTr68jmL/sG6XmV7/uDeWLC7QXvZT+eyBf1+uT/rw /Jz0qzWn7u2ukQiZNLPzhf3rpCLVW7Ihcx/9/+O0xjFe9cdtnukqB6PVaz5V3lY60L0+qHmH EktxRqKhFnNRcSIAxfertiACAAA= On Wed, 09 Jan 2013 12:00:34 +0530 rahul wrote: > 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] You're not exactly doing anything wrong, but quoting here has alwas been a bit funny to allow (some forms of) pattern matching. To ensure an exact string match you can use the (e) flag... % print $FOO[(ie)$x] 1 % print $FOO[(ie)$y] 2 pws