logoalt Hacker News

egorfinelast Wednesday at 11:51 AM2 repliesview on HN

I'm not against it. Absolutely go for it.

I just wonder what was the reason to port it and then I would like to have a word with a real living person who is actually using that shell.


Replies

WorldMakerlast Wednesday at 6:47 PM

PowerShell lends itself really well to writing cross-platform shell scripts that run the same everywhere you can boot up PowerShell 7+. It's origins in .NET scripting mean that some higher-level idioms were already common in PowerShell script writing even before cross-platform existed, for instance using `$pathINeed = Join-Path $basePath ../sub-folder-name` will handle path separators smartly rather than just trying to string math it.

It's object-oriented approach is nice to work with and provides some nice tools that contrast well with the Unix "everything is text" tooling approach. Anything with a JSON output, for instance, is really lovely to work with `ConvertFrom-Json` as PowerShell objects. (Similar to what you can do with `jq`, but "shell native".) Similarly with `ConvertTo-Json` for anything that takes JSON input, you can build complex PowerShell object structures and then easily pass them as JSON. (I also sometimes use `ConvertTo-Json` for REPL debugging.)

It's also nice that shell script parameter/argument parsing is standardized in PowerShell. I think it makes it easier to start new scripts from scratch. There's a lot of bashisms you can copy and paste to start a bash script, but PowerShell gives you a lot of power out of the box including auto-shorthands and basic usage documentation "for free" with its built-in parameter binding support.

MattSteelbladelast Wednesday at 12:37 PM

I believe this was the original announcement https://azure.microsoft.com/en-us/blog/powershell-is-open-so.... I have used it on Linux and it is included by default in Kali and ParrotOS.