Live data from Hacker News

PowerShell is open sourced and is available on Linux

azure.microsoft.com

281–290 of 790 posts

Re: PowerShell is open sourced and is available on Linux

#281
post #223

Earlier quoted context omitted.

> the only people I've seen say nice things about powershell are microshit fanboys that don't know any better. I really like Powershell. If you install RHEL or Fedora I'm the 'mikem' in the default /etc/sudoers file.

Uh, okay?

I've been using bash for 20 years, trained a few hundred RHCEs, and spent a large part of my life working for Red Hat and then IBM's dedicated Linux group. So yeah maybe I don't know any better, but that's because I haven't encountered it before. Piping objects to 'where' and 'select' is simply a better approach than scraping text. The implementation details - having to use .net to make cmdlets - aren't great but the fundamental idea of powershell is excellent.

Re: PowerShell is open sourced and is available on Linux

#282

Having powershell + bash on linux lets me compare this way: powershell, 14 pids(threads?), 3119M Virt size, 80160kb Resident. bash, 1 pid, 22068kb Virt, 3976kb Resident. And this is simply starting the process to an idle prompt. This is on a Debian 8 64bit system. (using their Ubuntu 14.04 binary)

I'm not a huge fan of PowerShell but you're not really making a good comparison here. Bash is "just a shell" that executes commands with a few bits of syntactic sugar here and there to make it easier to string those commands together and perform some primitive logic.

PowerShell is basically an interpreter that works more like a Java Virtual Machine. Consider the hypothetical example that you need to lookup 100 users in an LDAP directory from Bash: You run the openldap command 100 times in a loop. That's 100 processes that need to fork and quit in a serial fashion in order to perform the task at hand.

To do the same thing in PowerShell you'll be calling a native PowerShell LDAP API which will execute all 100 lookups without having to fork any separate process resulting in a vastly faster execution.

It's better to think of PowerShell like the Python or Ruby interpreters. IMHO, PowerShell is a vastly superior improvement to cmd.exe as a shell but on a Unix host it will be inferior to bash for day-to-day tasks.

Re: PowerShell is open sourced and is available on Linux

#283

Earlier quoted context omitted.

I wrote a bash script to sort processes by age on an old redhat 4 machine. What sounded like a very simple thing, quickly ended up being a complete nightmare of bash, python, and an unholy bunch of linux commands. It was ugly, and a terrible way of doing it, but we got it working. It would have been amazing if i could pipe PS into something that could sort by the dates on the 4th column, and return the last column in…

Pretty sure the section in the `ps` man page called OBSOLETE SORT KEYS indicates that even the `ps` on very old redhat machines could do this out of box... see the field `start_time`. Failing that, consider the `etimes` field (seconds since process was started) used in conjunction with the -o feature (control output format) so you can put `etimes` up front then simple pipe the output to `sort`. Those things being sai…

Honestly it was a quick and dirty one-time project, and I just needed to cobble something together.

I was more just commenting on the fact that with a "strongly-typed" shell some of this stuff becomes much easier without every single tool needing to add all these options.

It gets much more "Unix Philosophy" when every command doesn't need it's own sorting logic, and doesn't need it's own date display logic, and doesn't need it's own way of displaying it to the user.

It can output an object, which can be piped into another program to use what it needs which can be piped to something else to do some sorting which can pipe it out to another to display it in a nice table.

Re: PowerShell is open sourced and is available on Linux

#284

Earlier quoted context omitted.

I Can Only See One Problem With PowerShell :)

Powershell is case-insensitive, so feel free to avoid that shift key if you're so inclined :)

Been using PS for a long time and I had no idea about this. Thanks !

Re: PowerShell is open sourced and is available on Linux

#285

Earlier quoted context omitted.

For programming , I agree. However, Python doesn't work as a system shell; for that, you want something optimized for running commands, without having to wrap them in a function call with a list of arguments as strings.

did you try xonsh?

I did, and i found it a pretty big chore in practice. Its two modes (shell mode and python mode), never quite knowing which one you're in, I could never quite get used to that. PowerShell doesn't have this problem, because it was designed for the command line first and for scripts second (which is, incidentally, also its major downside if you ask me).

Re: PowerShell is open sourced and is available on Linux

#286

Earlier quoted context omitted.

I don't see a tremendous amount of accumulated wisdom in Powershell. It may be newer, but I'm not sure they looked at prior art or had design members who were shell gurus in any other shell than `cmd.exe`, which is a horrific shell. Why are commands horrendously long in powershell? If you spend time in the shell, you don't want your fingers falling off due to overuse. Aside... one of the design decisions Microsoft to…

> Aside... one of the design decisions Microsoft took that absolutely blows my mind is using `\` for file hierarchies instead of `/` That decision goes back to MS-DOS 2.11, circa 1983. (DOS 1.0 didn't have subdirectories.) The model for DOS directories came from UNIX, which at that time was the very aggressively defended intellectual property of AT&T. As Microsoft was an AT&T licensee -- for Xenix, their version of A…

They used \ for directories because most DOS programs used / for switches.

https://blogs.msdn.microsoft.com/larryosterman/2005/06/24/wh...

Re: PowerShell is open sourced and is available on Linux

#287
post #220

Earlier quoted context omitted.

C# incidentally solved many other shortcomings with Java. The languages are getting closer to parity, but for many years C# was pretty far ahead (if you only consider language features and not tooling/ecosystem). Between reified generics, better native interop, and many functional features, C# felt and feels more concise than idiomatic Java. And I've written plenty of both. Disclaimer: MSFT employee expressing person…

In what way was C#'s tooling not better?

Java seemed to have a lot more options for deployments and monitoring for a long time. More advanced 3rd party libraries in general. It had simply been around longer and thus had those tools available. Now that C# has been standard for a while almost all of those tools have a C# equivalent.

As a .NET dev I'd actually argue that the things available to C# now are actually better (especially Visual Studio), but that's certainly biased.

Re: PowerShell is open sourced and is available on Linux

#288

People laugh at me when I tell them I switched "back" to Windows after decades of Unix and Mac programming. But it's a really good, productive platform. Microsoft really seems to be heading in the right direction now. I hope .NET starts taking off on other platforms, too, because it really is a much better system than Brand "J".

If you meant Java, say Java please. Brand "J"? To me, that would mean J/K/APL/APL2 (MATLAB, Nial, S, R, and other array systems). But I guess Brand "J" is cute.

Re: PowerShell is open sourced and is available on Linux

#289
post #232

Earlier quoted context omitted.

[Disclaimer: I work for Microsoft.] As far as I recall, the original impetus behind what became PowerShell (as handed down to us in a conference room by Ballmer himself, sometime around 2001) was to fill the gap between ops people who did enterprise administration manually with tools like MMC and engineers who automated enterprise administration with tools like C++/DCOM. The latter were necessary in a lot of cases, b…

> So, yes, someone did ask for it - the IT industry. ... who couldn't use the well-known mature shell tools since they were locked into a closed platform, and Windows' cmd.exe was comparatively very weak.

It wasn't cmd that was the problem (although, it is weak); it was how Windows exposed APIs to allow automated solutions.

You had two options: VBScript (which is a glorified COM+ agent) or a "real" programming language like VB6/C# which mixed COM+ with Win32 API calls (which are too hard to use for most non-programmers).

Powershell within itself does improve CMD. But that isn't primarily how PS pushed Windows automation forward, Microsoft said that every major server feature and server function should work in Powershell, so engineers at Microsoft had to look at it (be it their lacking COM+ interface, provide a new PS interface, or something else).

The net result isn't that CMD got replaced by something better. It is that we have a lot more APIs and ways of interacting with Windows features and services than we ever used to.

The ironic thing is that today you could write MS Dos-style console applications that work in CMD which provide all of this new automation functionality because of the Powershell push. Back before Powershell you'd have to hack it using unsupported APIs, registry entries and similar.

Re: PowerShell is open sourced and is available on Linux

#290
post #275
post #272

Earlier quoted context omitted.

What about: ip addr show | grep inet Edit: wrote back original command and replied below instead

That doesn't work on my CentOS box. [kapil@localhost ~]$ ip addr show | grep inet inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host inet 192.168.128.236/24 brd 192.168.128.255 scope global dynamic eth0 inet6 fe80::215:5dff:fe80:501/64 scope link [kapil@localhost ~]$

Correction then:

    ip addr | grep "inet " | cut -f 3 -d " "
Post reply on HN