zsh-workers
 help / color / mirror / code / Atom feed
From: "Nikolay Aleksandrovich Pavlov (ZyX)" <kp-pav@yandex.ru>
To: Peter Stephenson <p.stephenson@samsung.com>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: expr length "$val" returns the wrong length for values containing NULL (\\0)
Date: Thu, 10 Dec 2015 20:47:40 +0300	[thread overview]
Message-ID: <367081449769660@web18g.yandex.ru> (raw)
In-Reply-To: <20151210093757.6e56f161@pwslap01u.europe.root.pri>

10.12.2015, 12:38, "Peter Stephenson" <p.stephenson@samsung.com>:
> On Thu, 10 Dec 2015 15:30:03 +1030
> D Gowers <finticemo@gmail.com> 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


      reply	other threads:[~2015-12-10 17:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10  1:52 D Gowers
2015-12-10  3:56 ` Nikolay Aleksandrovich Pavlov (ZyX)
2015-12-10  4:18   ` D Gowers
2015-12-10  4:29     ` Nikolay Aleksandrovich Pavlov (ZyX)
2015-12-10  5:00       ` D Gowers
2015-12-10  9:37         ` Peter Stephenson
2015-12-10 17:47           ` Nikolay Aleksandrovich Pavlov (ZyX) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=367081449769660@web18g.yandex.ru \
    --to=kp-pav@yandex.ru \
    --cc=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).