From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5086 invoked by alias); 10 Dec 2015 09:38:04 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37375 Received: (qmail 4669 invoked from network); 10 Dec 2015 09:38:02 -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 autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f4-f79026d00000418a-87-566947f7f1f0 Date: Thu, 10 Dec 2015 09:37:57 +0000 From: Peter Stephenson To: "zsh-workers@zsh.org" Subject: Re: expr length "$val" returns the wrong length for values containing NULL (\\0) Message-id: <20151210093757.6e56f161@pwslap01u.europe.root.pri> In-reply-to: References: <2007121449719799@web8h.yandex.ru> <1926681449721747@web1m.yandex.ru> 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+NgFrrELMWRmVeSWpSXmKPExsVy+t/xK7rf3TPDDI7OkrY42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGb92XWcueMNWsXrlKsYGxgOsXYycHBICJhL3X09jg7DFJC7c Ww9kc3EICSxllNi1dTMzhDODSWLuhe+MEM45RonX104yQThnGSWOP+hnB+lnEVCVePpqIxOI zSZgKDF102xGEFtEQF/i4p9bYLawQLRE2/ZPYLt5Bewl3p9uYwaxOQWCJe7vu8QOMXQVk8TR O9PBjuIHar769xMTxIH2EjOvnGGEaBaU+DH5HguIzSygJbF5WxMrhC0vsXnNW7ChQgLqEjfu 7mafwCg8C0nLLCQts5C0LGBkXsUomlqaXFCclJ5rqFecmFtcmpeul5yfu4kREtJfdjAuPmZ1 iFGAg1GJh9dBLjNMiDWxrLgy9xCjBAezkgjvGjegEG9KYmVValF+fFFpTmrxIUZpDhYlcd65 u96HCAmkJ5akZqemFqQWwWSZODilGhhrnZMFGZY8KrLkV/ir2rDMfWdq6JdVBVYza+/fe/HK ekNXfed9jVOPCvUf2by545a8wnBCVpuX94Ylj56qT6y/5v+pKqSc00akoctvY/DP3QKr4oxV T6SukX4WPK3q/5tigfMxB29sae0s3iKcxpD3klniQo10esEG1TDRh402+qdtmIs4JZRYijMS DbWYi4oTAVi0FNplAgAA On Thu, 10 Dec 2015 15:30:03 +1030 D Gowers wrote: > I am aware of the prevalence of NUL-terminated strings, since I've coded in > C in the past, that's why I wrote 'considerable bother to fix it'. > Nevertheless, for a purpose such as argument passing, size + data is > clearly better (easier to secure and more flexible) The main point here --- which doesn't seem to have been mentioned --- is that expr isn't a shell builtin. Within the shell, we do indeed treat NUL characters as normal chracters. As soon as you pass them outside, you are stuck --- there's no mechanism nor even convention for passing embedded NULLs which would require a rethink about the standard library conventions. This is a problem, but not a shell problem. So if you want to continue the argument, you'll need to find some higher power mailing list. pws