3 ms·
Newline separated what? Basically all Linux config files are newline separated lines, but that won’t get you the equals separated data pairs, indented blocks, p
by jodrellblank 6y ago
Newline separated what? Basically all Linux config files are newline separated lines, but that won’t get you the equals separated data pairs, indented blocks, pretend-xml sections, ad-hoc boolean representations, INI-style sections, ad-hoc list-of-values style data out of them.
> What if it allowed parsing of XML natively, allowing instant scrapers to be written in a single command?
Powershell’s Invoke-RestMethod parses xml natively to a structured output; it’s useful but not enough to make XML fun or trivial to work with beyond root.node.foo.title simple scraping.
- cnity 6y ago> Newline separated what? What I meant by this is that the newline character is the primary delimiter of the data, but I take your point. IMO, the best way to tackle the myriad ways of structuring data is to write parsers for them, not to rewrite the programs themselves to work with your shell's idea of structured data. That's a losing battle.
- jodrellblank 6y agoThis is how I felt powershell ought to go on Linux - parsers from every config format to a common intermediate and back, argument completers for every common shell command to a standard intermediate representation. I think that’s a losing battle as well due to the brittle nature, any tweak to any command output could break something, meaning endless maintenance work on a large scale. Rewriting concepts into new commands at least bring consistency and a chance of shrinking maintenance work as it settles on a nice design - and if not the maintenance won’t be endless rebuilds of the same parsers.
- AnIdiotOnTheNet 6y agoInteresting note: newlines are perfectly valid characters in file names. In fact, the only byte that cannot be in a file name is '/'[0], which means that you're asking for trouble trying to parse the in-band signaling you have to do with a stream that's pretending to be structured. [0] with a hex editor it is possible to create a file system entry using '/' in its name. Linux does not handle this situation with grace.
- kbrazil 6y agojc[0] does this for many commands and file-types, including .ini and key/value pair files with various delimiters and comment identifiers. [0] https://github.com/kellyjonbrazil/jc https://github.com/kellyjonbrazil/jc (disclaimer: I am the author)