4 ms·
Structure in streams seems to have suddenly added a whole lot of complexity and work, and for what? Being able to stream a collections of bytes (and collection
by swhipple 12y ago
Structure in streams seems to have suddenly added a whole lot of complexity and work, and for what?
Being able to stream a collections of bytes (and collections of collections of bytes, recursively) is one case that I find myself wanting when sending data between programs at the command line.
Consider:
ls "$pid_directory" | xargs rm
This, of course, has problems for some inputs because ls is sending a single stream and xargs is trying to re-parse it into a collection on which to use rm.
If there were some way to encode items in a collection OOB, you could pipe data through programs while getting some guarantees about it being represented correctly in the recipient program. (Sometimes you see scripts that do this by separating data in a stream with NUL delimiters, but this doesn't work recursively or if your main data stream might have NUL in it.)
- ackalker 12y ago>Being able to stream a collections of bytes (and collections of collections of bytes, recursively) is one case that I find myself wanting when sending data between programs at the command line. If you don't mind using JSON as intermediary format, you might like to have a look at jq: http://stedolan.github.io/jq/ http://stedolan.github.io/jq/ jq can also convert raw (binary) data to JSON objects containing strings (and vice versa) for further processing. Naturally, jq filters can be pipelined in many useful ways.
- Freaky 12y agoThere's work ongoing on FreeBSD to add libxo support to tools in the base system, which will allow you to get (amongst others) JSON out of various commands: https://github.com/Juniper/libxo https://github.com/Juniper/libxo