3 ms·
Powershell feels like it was designed by people who expect the underlying app to natively structure its data before handing it off to the shell. Typical Micros
by __MatrixMan__ 1y ago
Powershell feels like it was designed by people who expect the underlying app to natively structure its data before handing it off to the shell. Typical Microsoft, acting like they own the place and expecting others to conform.
Nushell on the other hand takes the (IMO more pragmatic) stance that the underlying app will most likely be writing strings to stdout and it's the shell's job to make it easy to discern the structure in those strings.
Perhaps a powershell wizard can show me that I'm wrong about this, but my feeling is that the powershell equivalent to this nushell is going to either call some external program (in addition to docker) or be quite messy:
$ docker ps | detect columns | where NAME == "foo"
- yorwba 1y agoI think the Powershell cmdlet "ConvertFrom-Csv" does functionally the same thing as "detect columns" in nushell. Though in this case it's probably better to make docker output structured data using "--format '{{json .}}'" and parse that instead of the human-readable representation.
- __MatrixMan__ 1y agoRe: just asking for structured output and parsing it accordingly--you're absolutely right. Do that if you can. But merely concatenating processes which emit and consume data of known shape is something that the OS can do without an interactive shell. What you really need a shell for is those situations where a bit of duct tape and string is needed to keep the bits flowing... when "--format '{{json .}}'" doesn't work. Re: ConvertFrom-Csv, touche, but I'm going to guess that it's not prepared to handle cases where the delimiter also appears in the output (spaces in this case). $ docker ps | detect columns | select CREATED STATUS | get 1 # ConvertFrom-Csv equivalent ╭─────────┬───────╮ │ CREATED │ weeks │ │ STATUS │ 9 │ ╰─────────┴───────╯ Nushell's answer here is --guess, which counts characters to determine how far from the left the column starts. $ docker ps | detect columns --guess | select CREATED STATUS | get 1 ╭─────────┬─────────────╮ │ CREATED │ 2 weeks ago │ │ STATUS │ Up 9 days │ ╰─────────┴─────────────╯ I'm not trying to bash pwsh, It's just that they're just trying to be different kinds of thing.