From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11461 invoked from network); 13 Sep 2004 18:26:39 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Sep 2004 18:26:39 -0000 Received: (qmail 51781 invoked from network); 13 Sep 2004 18:26:31 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Sep 2004 18:26:31 -0000 Received: (qmail 28232 invoked by alias); 13 Sep 2004 18:26:18 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20368 Received: (qmail 28222 invoked from network); 13 Sep 2004 18:26:17 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 Sep 2004 18:26:17 -0000 Received: (qmail 51012 invoked from network); 13 Sep 2004 18:25:18 -0000 Received: from moutng.kundenserver.de (212.227.126.184) by a.mx.sunsite.dk with SMTP; 13 Sep 2004 18:25:16 -0000 Received: from [212.227.126.179] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1C6vVs-0002by-00 for zsh-workers@sunsite.dk; Mon, 13 Sep 2004 20:25:16 +0200 Received: from [84.135.57.113] (helo=buddha.localdomain.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1C6vVr-0002Pu-00 for zsh-workers@sunsite.dk; Mon, 13 Sep 2004 20:25:15 +0200 Date: Mon, 13 Sep 2004 20:25:17 +0200 From: "Matthias B." To: zsh-workers@sunsite.dk Subject: BUG: tied parameters with NUL-separator Message-Id: <20040913202517.79418def@buddha.localdomain.de> X-Mailer: Sylpheed version 0.9.8claws (GTK+ 1.2.10; i586-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:95d11223a40b7ac6df081cef1fe1fef2 X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 The following works as expected in zsh 4.2.1 (NOTE: hexd is a hexdump script that displays offset: hex correspondingchars) pmt> unset foo pmt> unset bar pmt> sep=: pmt> foo='a:b:c' pmt> typeset -T foo bar "$sep" pmt> echo -n "${bar[1]}" | hexd 00000: 61 a pmt> echo -n "${bar[2]}" | hexd 00000: 62 b pmt> echo -n "${bar[3]}" | hexd 00000: 63 c pmt> bar[3]='1 2' pmt> echo -n "${bar[3]}" | hexd 00000: 31 20 32 1 2 pmt> echo -n "$foo" | hexd 00000: 61 3a 62 3a 31 20 32 a:b:1 2 Now look what happens when I use NUL as separator pmt> unset foo pmt> unset bar pmt> sep=$'\0' pmt> foo=$'a\0b\0c' pmt> typeset -T foo bar "$sep" pmt> echo -n "${bar[1]}" | hexd 00000: 61 a pmt> echo -n "${bar[2]}" | hexd 00000: 20 62 b pmt> echo -n "${bar[3]}" | hexd 00000: 20 63 c pmt> bar[3]='1 2' pmt> echo -n "${bar[3]}" | hexd 00000: 31 20 32 1 2 pmt> echo -n "$foo" | hexd 00000: 61 20 62 31 20 a b1 So we have 2 bugs here: 1) When typeset -T splits foo it inserts a space in front of all elements but the 1st one. This only happens when splitting apparently. Assigning to an element directly does not insert a space. 2) Re-assembling the scalar doesn't work. The separators are not inserted at all and the part after the space in the string '1 2' assigned to element 3 gets lost somehow. I know that I probably shouldn't complain. I'm actually quite impressed that embedding NULs in strings works at all. Few C-programs have binary-clean string-handling. But it's such a useful feature and since it works almost perfectly already I'm hopeful that this can be made to work fully. I'm really looking forward to this, because I want to parse output from find into an array and since pathnames can in theory contain every character but NUL, using NUL as separator seems to be the only way to achieve this. Bug 1) is the important one for me as I'm only interested in splitting, so a fix for that would be appreciated even if Bug 2) would take too much effort to fix. MSB -- pragma est dogma.