Live data from Hacker News

Linux Bash vs. Windows PowerShell

vedipen.com

71–80 of 93 posts

Re: Linux Bash vs. Windows PowerShell

#71
post #69

Earlier quoted context omitted.

PowerShell commands are not case sensitive. Commands use - structure, for example Get-ADUser gets an AD user. Once you learn that, it's easy to know that the equivalent command for AzureAD is Get-AzureADUser. It did take me a while to get used to it, but it does make sense, and it makes it easier to learn/remember commands.

I know about the lack of case sensitivity, but in idiomatic Powershell, it's Pascal-Kebab-Case. If I use a language, almost everyone else's code is going to be idiomatic, so I would write idiomatic code too.

Thats silly. You can equally complain about short vs long parameter names with most CLI tools (- vs --).

You also have tools for that just write short and use Expand-Alias

Re: Linux Bash vs. Windows PowerShell

#72
post #69

Earlier quoted context omitted.

I know about the lack of case sensitivity, but in idiomatic Powershell, it's Pascal-Kebab-Case. If I use a language, almost everyone else's code is going to be idiomatic, so I would write idiomatic code too.

Thats silly. You can equally complain about short vs long parameter names with most CLI tools (- vs --). You also have tools for that just write short and use Expand-Alias

Well... yes, I suppose it is a bit silly! I've really tried to like it, but I just can't get past it.

It's just my personal preference, but I've come across quite a few others who dislike the naming of Powershell commands too - seems to be a real love/hate kind of thing.

Re: Linux Bash vs. Windows PowerShell

#73
post #51
post #46

The biggest issue in PowerShell is very slow script execution startup time, 300-500ms seems to be typical. So forget about externally launching PowerShell scripts thousands of times. The second biggest issue I've seen is generic lack of robustness and maturity. Default cmdlets do the common case nicely, but once you have something unusual in the mix things go wrong fast... By unusual, I mean things like filesystem ju…

It very much is documented. Get-Help about_Redirection Received wisdom about Write-Host, by the way, is that one rarely wants it.

> Received wisdom about Write-Host, by the way, is that one rarely wants it.

Yeah, totally got that. But how else you can generate colorized easy-to-read output, where yellow warnings stand out?

There should be something like Write-Host that outputs colors to console stdout handle and silently drops color properties when writing to (anonymous) pipe stdout handle.

Color escape codes could be even better.

Re: Linux Bash vs. Windows PowerShell

#74
post #70

Earlier quoted context omitted.

> Article might be more successful if it demonstrated some of the advantages of PowerShell, such as returning the output as objects instead of lines, and what you can do with them as a result. The costs of doing this don't get enough mention though. You're essentially locking yourself into an ecosystem. It's typical in bash to have a pipeline where every program is written in a different language -- shell scripts, Py…

PWSH runs on top of the .NET runtime. So you can use any CLI language to write your code: C++, C#, VB, F#, Python, as well as PWSH.

So you're locking yourself into an ecosystem. You have to replace everything with .NET.

Even existing things that are written in C++ or Python would have to be specifically rewritten to input and output .NET runtime objects. And why use that rather than any other object format that isn't tied to a specific vendor?

Re: Linux Bash vs. Windows PowerShell

#75
I use PowerShell for quite some time (mostly windows/.NET guy here) and it would be great tool except one thing: the amount of not obvious quirks is astounding and not really decreased over the years. Probably because of avoidance of breaking changes, which is understandable where there are tons on powershell scripts out there. But for for someone who uses it mostly as a shell to write one liners or occasionally write a script not longer than 30 lines of code, it's really discouraging when you encounter again some unexpected behavior (even though you thought you learned powershell "good enoguht" couple years ago).

Re: Linux Bash vs. Windows PowerShell

#76

I dev on a Mac and do a lot of 'quality of life' scripting with Bash. I recently had to do something on a PC and figured I'd try out Powershell. I have to say, it was a joy. Dealing with objects instead of text is so refreshing, it really is a game changer especially when you start integrating with COM (e.g. excel). The only things I found worse: 1 - error handling doesnt bubble in the same way. e.g. I can't do an eq…

As people mentioned there is `$ErrorActionPreference = "Stop"` but it's not equivalent to bash `set -e`. Looks like there is no consensus if we'll get something similar in the near future (https://github.com/PowerShell/PowerShell-RFC/pull/88)

Re: Linux Bash vs. Windows PowerShell

#77

I use PowerShell for quite some time (mostly windows/.NET guy here) and it would be great tool except one thing: the amount of not obvious quirks is astounding and not really decreased over the years. Probably because of avoidance of breaking changes, which is understandable where there are tons on powershell scripts out there. But for for someone who uses it mostly as a shell to write one liners or occasionally writ…

Yes, this could be problematic. But any language has this kind of quirks (rust, ruby etc.). The problem is not like with C where you have quirks forever.

Once you learn it, you know about them.

Re: Linux Bash vs. Windows PowerShell

#78
post #72

Earlier quoted context omitted.

Thats silly. You can equally complain about short vs long parameter names with most CLI tools (- vs --). You also have tools for that just write short and use Expand-Alias

Well... yes, I suppose it is a bit silly! I've really tried to like it, but I just can't get past it. It's just my personal preference, but I've come across quite a few others who dislike the naming of Powershell commands too - seems to be a real love/hate kind of thing.

You should get over that trivial reason really. You are missiong out a lot.

Re: Linux Bash vs. Windows PowerShell

#79

Earlier quoted context omitted.

I absolutely abuse Bash for more usecases than I should on my mac, but you owe it to yourself to try out Powershell Core on PC. It is very, very productive. If it weren't for a couple nuances, I would consider switching to it on my Mac as well.

PowerShell takes some time to grok, but once you get it it has very deep integration with Windows systems, and can become a joy to work with. That being said, I still feel violated every time `ls` returns `bad command or filename`

You could always make aliases. For example, ls would be 'wsl ls' to run the ls command from Linux instead of searching down the Windows exec path for it.

Also, I noticed at least my version of powershell actually has a built in 'ls'. It isn't quite the same as 'wsl ls' but it does show results more appropriate for Windows file systems.

Re: Linux Bash vs. Windows PowerShell

#80
Having used both, in a personal and professional capacity, I don't think they occupy the same "real estate". If you have a bunch of Windows systems to admin, sure, PowerShell works great with all the Windows built-ins. In fact, it works with SCCM pretty well. If your systems are Linux-based, you can use shell scripts to interface with something like Chef or Rundeck. Use something that works natively and is designed for the platform you need to orchestrate.
Post reply on HN