3 ms·
It's even worse than that (from a practical standpoint, not a complexity theory standpoint) when you get into the realm of interpreted languages written in C. T
by chongli 11y ago
It's even worse than that (from a practical standpoint, not a complexity theory standpoint) when you get into the realm of interpreted languages written in C. Try processing text containing null bytes in bash, for example.
- jstimpfle 11y agoData containing null bytes is not text. I like to think of bash / sh as just a job control system. It enables you to setup process pipelines. Everything is just processes and files (streams). Variables only serve as programs arguments. Since program arguments are also null terminated, variables containing null bytes just make no sense. (Of course it gets dirty as soon as you feed the output of a job into a variable, for example. I think that isn't even defined by POSIX for non-text streams).
- chongli 11y agoFeeding the output of a job into a variable is a common enough task. One example I worked on recently was to use the results of one find(1) command as an array of arguments to another. Perhaps this was a very ugly way of comparing two directories, but it worked. This is why it surprised me when I realized (without having thought about it) that variables can't contain null bytes. It made my quick id3 tag parsing script a bit trickier to write, since I could no longer just use read(1P).