From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22643 invoked by alias); 10 Dec 2015 17:55:11 -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: 37379 Received: (qmail 2252 invoked from network); 10 Dec 2015 17:55:10 -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,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1449769660; bh=FfqFcN2osdNVgXG2Rm/2kn0dhYSs5dQ36o/poFScvuQ=; h=From:To:In-Reply-To:References:Subject:Date; b=lFRmILIJqMR02g7JlsR2eFE6uPZf+jM6cWE+C1q/k05/+6BipY+gGnXwtMkdx2Q1z lQNUvfWylxWsHsfszZcC+KDAs/S4T2FBnyJgCe2QXWjIozkXC5F8Mlh2/HSUPnrCFx bznDOLLcfiV8Q4RkEKiA+ALANiSJVO3coSwEyzNI= From: "Nikolay Aleksandrovich Pavlov (ZyX)" To: Peter Stephenson , "zsh-workers@zsh.org" In-Reply-To: <20151210093757.6e56f161@pwslap01u.europe.root.pri> References: <2007121449719799@web8h.yandex.ru> <1926681449721747@web1m.yandex.ru> <20151210093757.6e56f161@pwslap01u.europe.root.pri> Subject: Re: expr length "$val" returns the wrong length for values containing NULL (\\0) MIME-Version: 1.0 Message-Id: <367081449769660@web18g.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Thu, 10 Dec 2015 20:47:40 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r 10.12.2015, 12:38, "Peter Stephenson" : > 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 It was not directly mentioned, but I did say that you need to write `expr` as a zsh function for this code to work as expected. > NUL characters as normal chracters. As soon as you pass them outside, > you are stuck --- there's no mechanism nor even convention for passing There actually is: use file descriptors in one way (pipes) or the other (temporary files, fd will be created by the program). This is most universal, and many programs work with data with NULs (e.g. `grep --null` with `xargs -0`). Still not everything supports this variant though. Most other variants I know include escaping/quoting of some sort and are much more ad-hoc. > 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