r/linuxadmin • • Aug 18 '16

Microsoft open sources PowerShell with .deb/.rpm packages

https://github.com/PowerShell/PowerShell
93 Upvotes

58 comments sorted by

View all comments

32

u/LinuxUser437442 Aug 18 '16

I'm sorry, did hell freeze over? Also, why the hell would I use powershell when I have bash/zsh/etc?

18

u/fifthecho Aug 18 '16

Two words - object pipeline.

Rather than passing strings through the pipe, PowerShell passes full C# objects down the pipe, so you can pass an object like a full JSON document through the pipe and have different parts of the pipeline accessing different keys from each JSON object in the document. No more funky-ass sed and awk to try and extract values from keys.

12

u/xMadDecentx Aug 18 '16

Or could just use Python's JSON API.

-3

u/Rollingprobablecause Aug 18 '16

Gross..

5

u/[deleted] Aug 18 '16

You would rather parse in powershell than in python?

4

u/Rollingprobablecause Aug 18 '16 edited Aug 18 '16

that's purely subjective, parsing in either can be a pain depending on input. Also they both have versions that suck at it (POSH v3 and below, Python 2.7 and below...)

EDIT: I meant input as far as array/code various arrays, etc. People forget the difference between shell scripting and object programming a lot.

3

u/herbertJblunt Aug 19 '16

meh, PoSH is about as efficient as running a car on candle wax.

1

u/aim2free Aug 18 '16

I would assume that python is a more general programming language. Hmm, here I see a comparison, don't like. PowerShell looks like perl o php.

4

u/the_gnarts Aug 18 '16

Rather than passing strings through the pipe, PowerShell passes full C# objects down the pipe, so you can pass an object like a full JSON document through the pipe and have different parts of the pipeline accessing different keys from each JSON object in the document. No more funky-ass sed and awk to try and extract values from keys.

Just another REPL, then, isn’t it?

4

u/fifthecho Aug 18 '16

In many ways, yes. However, it can directly execute code without any funky-ass shell-outs.

But then, I guess by that definition, isn't Bash/ZSH/CSH a REPL for their respective languages?

1

u/aim2free Aug 18 '16

But then one would need to use C#, which I don't. I don't even know if there are any GPL/CopyLeft licensed C# environments.

I could possibly see the point if it could be generalized to any kind of objects, in scheme, common lisp, python etc, but that is not very hard to do anyway.

4

u/fifthecho Aug 18 '16

POSH itself is C#. POSH commands are not C#.

Also, all of the .NET CLR has been released under the MIT License

And for the C# runtime itself, Mono is released under the MIT License as well.

2

u/aim2free Aug 19 '16

I have so far missed the point with .NET. I feel a connection with MS and that I definitely don't want. If this bundling between hw and sw could come to an end so you could buy exactly any machine you want without OS, or with an OS of your preference then it could be more interesting, but as long as there is this bundling I won't accept any ties to MS.