Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: expr length "$val" returns the wrong length for values containing NULL (\\0)



On Thu, 10 Dec 2015 15:30:03 +1030
D Gowers <finticemo@xxxxxxxxx> 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



Messages sorted by: Reverse Date, Date, Thread, Author