Am 02.03.16 um 09:20 schrieb Marko Rauhamaa:
Chris Angelico <ros...@gmail.com>:

On Wed, Mar 2, 2016 at 4:41 PM, Marko Rauhamaa <ma...@pacujo.net> wrote:
I was talking about JSON for the standard I/O, not the command-line
arguments, as in:

    ps -ef | awk '/httpd/ { print $2 }'

where "ps -ef" emits SPC-separated fields and LF-separated records, and
awk parses and processes them.

If you want to change that, you have to change the entire ecosystem,
not just the shell. You would have to teach every single program to
use a different structure.

Correct. There could be translation utilities in the interim.

A lot of programs already do support NUL-separation - usually with a
-z parameter or something. But you won't be able to magically get them
all to use JSON. And I doubt it would be advantageous anyway.

The advantages are obvious. Barely any programs do proper escaping, and
security problems abound.

Have a look at PowerShell. It's not Python, and it is from MS - but it works along those lines, passing .NET objects through the pipe. Owing to that, instead of $2=="something" in the awk progra, you can address the field(attribute) $2 by the correct name instead of a positional argument.

        Christian

Caveat emptor: never used it myself

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to