5 ms·
I've been a die-hard Linux user for about a dozen years. Recently I had to do some development with MS Powershell. I was very reluctant at first, but after gett
by tlhunter 7y ago
I've been a die-hard Linux user for about a dozen years. Recently I had to do some development with MS Powershell. I was very reluctant at first, but after getting familiar with the technology, I almost fell in love.
"Cmdlets", basically commands used in Powershell, output "objects" instead of the streams of text used in a more classical shell. Powershell has built-in tools to work with these objects. For example, you can take the output from one Cmdlet, pipe it through `SELECT` with a list of fields specified, and get a stream of objects only containing those fields. Other operations can be performed against those objects as well, such as filtering and whatnot.
Back to normal nix commands, we're starting to see more and more commands introduce direct JSON support [1]. There are even tools to translate output from common commands into JSON [2]. We'll probably see `jq` shipped directly with modern distros soon. Eventually we'll reach a tipping point where it's expected that command supports JSON output. Tools like `awk`/`sed` might get updated to have a richer support for JSON. Finally, we'll have ubiquitous Powershell-like capabilities on every nix machine.
Powershell _is_ available on Linux. The model of piping objects instead of JSON is both powerful and more efficient (For example, there's no redundant keys like in a stream of JSON objects, leading to less moving bytes, like how CSV headers aren't repeated with every row. Plus, binary data is smaller than text.) But, most developers are hesitant to switch out their shell and existing workflows for a completely new tool, which is why Powershell will likely only be adopted by a small subset of sysadmins.
[1] https://daniel.haxx.se/blog/2020/03/17/curl-write-out-json/ https://daniel.haxx.se/blog/2020/03/17/curl-write-out-json/
[2] https://github.com/kellyjonbrazil/jc https://github.com/kellyjonbrazil/jc
- majkinetor 7y agoNot only that, but pwsh support for objects doesn't stop on passing objects around and mapping to properties to parameters. There are number of mehanisms in place. All nix variants solve just 1 of those mechanisms. IMO, powershell should be added to ALL mainstream distros as first order citizen. There is no downside to that given that MS is now legit FOSS player and that anybody can fork in case something goes wrong along the way...
- jononor 7y agoHas Microsoft given some sort of explicit patent license for Powershell?
- majkinetor 7y agoIts MIT https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt https://github.com/PowerShell/PowerShell/blob/master/LICENSE...
- jononor 7y agoThat is a no then, as the MIT does not contain an explicit patent grant. So Microsoft could very well sue anyone using Powershell, using patents. We don't know if they would win, as there might (or might not) be some protection in a "implicit" grant that a copyright license give. But it would be a fight most organizations would not be willing to take, and would settle out of - a win for Microsoft in practical terms. It is not long ago since they did this with FAT32 against practically all Android manufacturers. Apache 2.0 would be the permissive license to go for if desiring to guarantee safety from patent issues. http://en.swpat.org/wiki/Patent_clauses_in_software_licences http://en.swpat.org/wiki/Patent_clauses_in_software_licences
- majkinetor 7y agoWhat are you talking about ? > deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so
- jononor 7y agoYeah that is the implicit grant. But maybe it is clearer in practice than I though. The Open Source case book regarding patents puts it in "Express but Non-Specific Licenses" https://google.github.io/opencasebook/patents/ https://google.github.io/opencasebook/patents/, and Scott K Peterson at Red Hat says its explicitness does not depend on the mention of "patent" https://opensource.com/article/18/3/patent-grant-mit-license https://opensource.com/article/18/3/patent-grant-mit-license
- Freaky 7y agoThough it's pretty immature, nushell has a similar idea, with its own internal data model being streams of structured, typed data: https://www.nushell.sh/ https://www.nushell.sh/ And back to nix commands, libxo is used by a chunk of the FreeBSD base tools to offer output in JSON, amongst other things: https://github.com/Juniper/libxo https://github.com/Juniper/libxo -% ps --libxo=json,pretty { "process-information": { "process": [ { "pid": "52455", "terminal-name": "5 ", "state": "Is", "cpu-time": "0:00.00", "command": "-sh (sh)" }, -% uptime --libxo=json,pretty { "uptime-information": { "time-of-day": " 8:34p.m.", "uptime": 1730360, "days": 20, Be nice to see more tools converted.
- gerdesj 7y ago# ip -j a | jq
- ramblerman 7y agoIs there a good source to get started with powershell, perhaps aimed at people with good bash knowledge. Every time I open it up I just nope back out, and most of the docs I peeked at didn't draw me in.
- vips7L 7y ago> But, most developers are hesitant to switch out their shell and existing workflows for a completely new tool, which is why Powershell will likely only be adopted by a small subset of sysadmins. What I would like to see is some sort of stddata stream be offered by the kernel itself so devs won't have to switch their shells and object manipulation can be a standard.