Live data from Hacker News

PowerShell is open sourced and is available on Linux

azure.microsoft.com

111–120 of 790 posts

Re: PowerShell is open sourced and is available on Linux

#111
post #56
post #17

Earlier quoted context omitted.

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…

You can use control-O for that, which does "execute this command as if I pressed enter, then when it's done bring up the following command in command line prompt". So if you have a set of commands to run that are 20 lines up in history, you can first find them (with 20x UP or by reverse-search), then just control-O control-O control-O control-O ... to execute them one after another.

Oh. My. God.

Life changing!

Out of curiosity, how did you discover that you could do this?

Re: PowerShell is open sourced and is available on Linux

#112
post #63

Earlier quoted context omitted.

Bash is awful. But so are shells in general. Even Rob Pike says as soon as your shell program gets longer than a few lines, write it in a proper language.

I feel that principle is true from all high-level languages as you move down the chain. Shell scripts should be 1-20 lines. Python/Ruby/whatever for 20-100 and compiled for anything >100.

I was about to refute you with a recent example of mine that just needed to serially execute a bunch of commands, and it's well over 20 lines. Then I remembered that I needed to introduce some branching logic, said "not in bash, I'm not", and rewrote it in Python.

So for me, it's not a matter of LoC but complexity. Need to copy file from here to there, then commit to git repo, blah, blah, blah, then kick off a build? Whether it's a 1000 lines or 2, I don't have a problem with doing that in bash. But as soon as I need some logic (or on rare occasions, perf), I go to something else.

Given that, why do you cut shell scripts off at 20 lines? I ask in the spirit of being open to the possibility that maybe I'm doing it wrong. :-)

Re: PowerShell is open sourced and is available on Linux

#113

Wow. I've been very impressed with Microsoft lately. They could have easily set themselves up as the next IBM, in the sense of being a monolithic corporation relying on corporate practices, but they've been spewing some crazy fun things that shows they're not out of the league yet. Might just be MY miscontrued perception that microsoft was becoming old/monolithic, but really excited with the direction they are headin…

In response to the flagged sibling comment: I use Linux as my main OS and have almost non-stop since ages ago. I have in the past half-seriously wondered whether infamous projects that make Linux worse were MS false flag ops. But here, rather than making personal accusations (regardless of how true they might seem to you), it's probably more productive to provide a counterexample, a reminder of MS's negative behavior, or evidence that they haven't really changed. Then either people can see for themselves, or people within MS will see they still have a long way to go and keep pushing for change from within.

Re: PowerShell is open sourced and is available on Linux

#114
post #56

Earlier quoted context omitted.

You can use control-O for that, which does "execute this command as if I pressed enter, then when it's done bring up the following command in command line prompt". So if you have a set of commands to run that are 20 lines up in history, you can first find them (with 20x UP or by reverse-search), then just control-O control-O control-O control-O ... to execute them one after another.

I wasn't aware of this. Thank you. Not that I've been using Bash and zsh every day for twelve plus years...

[deleted]

Re: PowerShell is open sourced and is available on Linux

#115
post #56

Earlier quoted context omitted.

You can use control-O for that, which does "execute this command as if I pressed enter, then when it's done bring up the following command in command line prompt". So if you have a set of commands to run that are 20 lines up in history, you can first find them (with 20x UP or by reverse-search), then just control-O control-O control-O control-O ... to execute them one after another.

I wasn't aware of this. Thank you. Not that I've been using Bash and zsh every day for twelve plus years...

Seems to be an instance of Cunningham's Law:

https://meta.wikimedia.org/wiki/Cunningham%27s_Law

Re: PowerShell is open sourced and is available on Linux

#116
post #107
post #32

Earlier quoted context omitted.

Is this really so useful in practice? I have never used PowerShell before (nor do I have plans to do so in the near future), but I would imagine the downside is complexity, both for user and especially for developers. With text you just read and parse, while with objects you need to know the object type, its fields,... Whatever happend, I hope text stays here (and I have a bad feeling about it ever since I met system…

I find it massively useful in practice, even for mundane tasks. For example, the other day I was trying to search the columns of a very large SQL Server table¹ but also needed information about the column type. …\dbo.site> ls Columns | select Name, DataType, {$_.Properties['Length'].Value} | where {$_.Name -like '*int*'} Name DataType $_.Properties['Length'].Value ---- -------- ----------------------------- internal_…

> Quick, easy. In a *nix shell that would be very tricky.

You'd probably need to make an explicit SQL query since you wouldn't have the database integration.

Re: PowerShell is open sourced and is available on Linux

#117
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.

I wonder the same, but I hope it succeeds.

When PowerShell was written we knew more than when Bash, let alone the original Bourne Shell was designed. Powershell understands that parsing is sometimes hard. Powershell does not invite data-insertion attacks with the the fervour of Bash. In short, it does many things right that would Bash do too if it could be rewritten.

And yet -- I've rarely found it useful in practice. But it's hard to judge that, since I don't do as much in Windows as I do on Unix. So this move will level the playing field a bit, and we shall have a fairer comparison.

Re: PowerShell is open sourced and is available on Linux

#118
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.

I think PowerShell would actually be way ahead of Bash. But we have things so much better than Bash. Python/Ruby let you do a lot of amazing stuff (not shells, I know, but still immensely more useful scripting languages than what you can do in Bash).

Also, if you're still using Bash, I'd highly recommend looking at newer shells. Fish is pretty amazing. I've been using it over over a year. There are others too like Zsh.

Re: PowerShell is open sourced and is available on Linux

#119
post #81

Earlier quoted context omitted.

Yes, this is so awesome. Can't remember the exact parameter/field? Just dump it to the console.

That what you would do with text? If you have no idea what its outputting, explore it by putting it to the console.

What you can't do so easily with text is also just auto-convert that object directly to JSON or YAML or CSV, for that matter, and forward that easily into your favorite JSON/YAML/CSV exploration tool.

Re: PowerShell is open sourced and is available on Linux

#120
post #83

Earlier quoted context omitted.

I love the strongly-typed cookies but I absolutely hate the powershell syntax. It's like C# and Bash got together and had a really ugly baby.

As long as you bear in mind that it's main purpose is a usable replacement for the CMD.EXE batch language, then you should be willing to forgive Powershell it's warts.

Except that they added a bunch of new warts that don't have any relation to CMD.EXE. They took the opportunity to re-invent how a shell works from the strongly-typed object perspective but then they copied some of terrible syntax of 40 year old unix shells. I just don't understand it.

I'd rather write scripts in pure C#.

Post reply on HN