Live data from Hacker News

PowerShell is open sourced and is available on Linux

azure.microsoft.com

131–140 of 790 posts

Re: PowerShell is open sourced and is available on Linux

#131
post #79

Great! So I can now run bash on windows (with WSL), open tmux, and open powershell prompts in each tab: the loop is complete! I wish powershell's documentation was a bit more clear about what's powershell 1.0, 2.0, 3.0... Etc. A lot of time I'd find a verbose and tedious way to do one thing because the code was written in "old powershell", when the latest version had a much more elegant solution (either because of ne…

I agree, there's been a lot of churn in the PS versions and it makes it hard. Especially when you're new to it and trying to learn.

Re: PowerShell is open sourced and is available on Linux

#132
post #111
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.

Oh. My. God. Life changing! Out of curiosity, how did you discover that you could do this?

It's been something I've used for many years, so I really don't recall any more just where I found out about it...

Re: PowerShell is open sourced and is available on Linux

#133

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…

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.

The implicit return semantics are insane, since you can implicitly early-exit when you do things like call ArrayList.Add (which returns a bool to indicate whether the thing was added).

Re: PowerShell is open sourced and is available on Linux

#134

Earlier quoted context omitted.

Very much so. They're returning to their roots(winning over developers with world-class tools) and it's really refreshing to see. Between this, VSCode and .NET Core it really is an impressive effort.

Let's hope the awesomeness they are showing on the developer relations side finally leaks into the Windows side and they stop their shenanigans with W10 and Android and VFAT patent threats. It's so disappointing to see this kind of split-brained behavior.

Nah, why should they?

Developers are pretty much the only demographic that might realistically switch operating systems, so they only really need to cater to them. The rest, they can pretty much treat however they want, and they won't lose them as customers.

Re: PowerShell is open sourced and is available on Linux

#135
post #61

Earlier quoted context omitted.

Scripting. While I typically use Bash on Windows to use grep to interactively test my webserver, I'm much happier using Powershell ISE (which I don't know was ported [1]) to write standard tests with multiple parts, particularly ones that require e.g. checking cookies on the response. 1. Looks like they ported a service that does the same. https://github.com/powershell/powershelleditorservices

Can you be more specific? Powershell instead of using grep? Or as a testing framework? Or an embedded interactive REPL? I mean, just broadly, with basically zero knowledge of powershell, what I see is a custom scripting language with a set of common 'macro' commandlets that do little tasks. ...but, I don't see how that's useful? How do you import a package to upload a file to S3? I can't just install https://aws.amaz…

Since it's only come out not all 3rd party scripts are going to available straight away.

but there are standard http post/get/put commands so you can write your own.

Re: PowerShell is open sourced and is available on Linux

#136
post #83

Earlier quoted context omitted.

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

The point of PowerShell isn't just to write scripts but to work as an interactive shell.

Re: PowerShell is open sourced and is available on Linux

#137
post #87

Cool! I'm having a play with it and it seems to work really nicely. Does anyone know why the following commands don't produce the same output? get-childitem | ConvertTo-Csv get-childitem | ConvertTo-Json | ConvertFrom-Json | ConvertTo-Csv It seems like, if there's a perfect underlying data model doing what's effectively an identity conversion shouldn't change anything. Edit oooo, and all the linux stuff is available…

ls and grep are aliases in powershell, so not exactly the same, but pretty close

For your first question: you have converted types. When you did a ConvertTo-Json, you serialized the System.IO.DirectoryInfo type into JSON compatible data. When you ConvertFrom-Json you have a PCSCustomObject.

The conversion to CSV is different for the System.IO.DirectoryInfo than the PSCustomObject. This has to do with the sub-types (converting from objects into serializable JSON objects). It also appears to handle time strings differently as well.

Re: PowerShell is open sourced and is available on Linux

#138
post #32

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…

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…

Yes, it's quite useful in practice, because the alternative is knowing exactly the format of text some command is going to produce and munging it, which is hardly better

Re: PowerShell is open sourced and is available on Linux

#139

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…

So many strongly typed shells exist already. I don't understand why arbitrary microsoft shit gets so much love for doing things that have already been done in the OSS world, and doing them poorly. PowerShell is a pile of shit.

Re: PowerShell is open sourced and is available on Linux

#140
post #116
post #107

Earlier quoted context omitted.

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.

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't want to trigger PTSD in anyone who's had to grep the output of ‘ps’ for anything non-trivial. (Plus, the database thing was something I actually did a few days ago.)

Post reply on HN