Live data from Hacker News

PowerShell is open sourced and is available on Linux

azure.microsoft.com

231–240 of 790 posts

Re: PowerShell is open sourced and is available on Linux

#232
post #93

Earlier quoted context omitted.

As a note, there have been strongly-typed shell languages for Unix for some time. Scheme Shell[0], Turtle[1] and TCSH[2] leap to mind; but there's nothing preventing a developer from using Perl, Python, Lisp or any other language that allows itself to accept stdin as an interpreted script. 0: https://scsh.net/ 1: http://www.haskellforall.com/2015/01/use-haskell-for-shell-s... 2: http://www.tcsh.org/Welcome Edit: oh m…

This is why I find PowerShell to be an answer to a question nobody asked. If bash/zsh isn't cutting it for you, drop into something like Python, Ruby or Perl to do the heavy lifting. PowerShell will never accumulate a library as comprehensive as what any of those three have, each has had decades to accumulate packages of all kinds, and more are still being added. It's odd, but not surprising given their history of "N…

[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, but they were expensive, and we needed to give the industry a way to do powerful automation without hiring a bunch of PhDs. So, yes, someone did ask for it - the IT industry.

Re: PowerShell is open sourced and is available on Linux

#233
post #140

Earlier quoted context omitted.

Well, yeah, but I mean the concept (grepping in tabular data). If, hypothetically, bash had database integration, ls Columns would probably return something like foo varchar 30 NOT NULL bar decimal 8 baz int 4 Which would be a royal PITA to search for anything in—if I were to search for ‘int’ I'd get all int columns and any columns with int in the name…. I could've used an example involving process lists, but I didn'…

ps aggregates /proc info for human viewing. Why grep the formatted output rather than the source data?

Maybe on Linux. OpenBSD doesn't even have procfs, FreeBSD deprecated it, DragonFlyBSD doesn't mount it by default.

/proc is a race condition waiting to happen, so I can't really say I recommend using that.

Re: PowerShell is open sourced and is available on Linux

#234
post #207

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…

It's entirely possible this is a recent development, but "ps -o cmd --sort etime" seems to do what you're asking for.

sadly that wasn't available, and researching an easier way to do it without that was met with pages and pages of people saying to do that...

Re: PowerShell is open sourced and is available on Linux

#235
post #207

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…

It's entirely possible this is a recent development, but "ps -o cmd --sort etime" seems to do what you're asking for.

There's literally an example in 'man ps' that does exactly this. It's right there in the output formatting section.

    ps kstart_time -ef

Re: PowerShell is open sourced and is available on Linux

#236
post #17
post #9

I'm always in favor of things being open-sourced, but I do kind of wonder in what universe I would use PowerShell when Bash is readily available.

As a full-time Linux user, I have to say that bash is overrated. For instance, on Windows I could press the up arrow through my history 20x to find a group of commands I want to run, press Enter, then press DOWN for the following command, then enter, then DOWN until I run them all. In Bash, I need to press UP 20x every single time. Yes, you can customize it a lot, and you can script it but default bash isn't that spe…

It's just default behavior and its customizable for a reason. Different people have different preferences, powershell's default behavior is in no way 'better' than bash's. You can also use a different shell like zsh.

Re: PowerShell is open sourced and is available on Linux

#237

Earlier quoted context omitted.

Powershell can use any .NET library... "Nobody" meaning you. Which is perfectly fine. But there are quite a few users of Powershell out there.

Now that it exists there are users, but when people were hoping for a modern or more portable replacement for DOS batch files I'm not sure this is what they had in mind.

Powershell In Action covers a bit of the history and decision making around powershell; interesting stuff.

Ultimately, given that powershell was initially targeted at systems admins/engineers and that Windows is highly object-oriented(in contrast to Linux's text streams), I believe Powershell was a apt development. Having done plenty of systems engineering across linux and Windows it seems to fit the needs of Windows pretty well; a fantastically unique shell that wouldn't have existed if not for Windows.

Re: PowerShell is open sourced and is available on Linux

#238
post #93

Earlier quoted context omitted.

As a note, there have been strongly-typed shell languages for Unix for some time. Scheme Shell[0], Turtle[1] and TCSH[2] leap to mind; but there's nothing preventing a developer from using Perl, Python, Lisp or any other language that allows itself to accept stdin as an interpreted script. 0: https://scsh.net/ 1: http://www.haskellforall.com/2015/01/use-haskell-for-shell-s... 2: http://www.tcsh.org/Welcome Edit: oh m…

I want to throw my support behind scsh! It's useful for those things that cross the boundaries between a program, and a shell script. I've found once you need functions for a shell program, it's time to step up to scsh. I also wish scsh ports were more well maintained so people could use their favorite schemes with scsh syntax, but it's quite a large codebase to port, so remember that it's scheme48 scheme.

bits of SCSH have been ported to every scheme out there now. And some have been improved. Irregex, in particular, is a dramatically improved version of the SCSH regex engine.

Re: PowerShell is open sourced and is available on Linux

#239

PowerShell is my guilty pleasure of the computing world. Once you've piped strongly-typed objects around between your shell commands, text scraping seems barbaric by comparison. The problem, of course, is that you can't use all that power for much, since the pool of PS-compatible tools and utilities is much shallower than it is for Unix shells. I'm really hoping this will help spur a new wave of PowerShell-compatible…

> Once you've piped strongly-typed objects around between your shell commands, text scraping seems barbaric by comparison

This is why Powershell is a great thing on Windows. Windows works with .Net objects and Powershell works directly with those objects.

It's also why I don't see the reason to be excited that it can run on OS X and Linux now, because neither of those systems work by passing .Net objects around. You parse text with bash/sed/awk/perl/python ... because *NIX works on text based config files and commands that output text.

Re: PowerShell is open sourced and is available on Linux

#240
post #192

Earlier quoted context omitted.

In my admittedly limited experience there seems to be at least 3 aliases for every keyword which makes reading someone else's code a real hassle sometimes. Our ops guys swear by it though.

You're supposed to avoid the aliases in scripts. Or that's what's recommended anyway.

Yes, this makes for much easier to read code for people down the road :)

I think OPS folks (myself included) sometimes create things thinking nobody but them will use them, then an occasion arises to share, and you're stuck with something functional but horrible to read.

It took just one such occasion for me to convert to writing everything from the perspective that 'other people may need to use this.'

Post reply on HN