Live data from Hacker News

Linux Bash vs. Windows PowerShell

vedipen.com

31–40 of 93 posts

Re: Linux Bash vs. Windows PowerShell

#32

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…

They added && recently, apparently.

Re: Linux Bash vs. Windows PowerShell

#33
post #9

I think PowerShell doesn’t really compete with Bash, it competes with Python, Perl or the like. And I haven’t found it to be superior in that aspect other than at integration with Windows system stuff.

No it doesn't. It is "shell language" designed for shell usage, not general purpose language, like Python.

Re: Linux Bash vs. Windows PowerShell

#34

If you need crossplatform scripting and will install a runtime, why go powershell or bash ? Something like ruby or python seems more adpated.

Its designed for shell usage, python, ruby and friends don't feel "native" in that manner and are simply akward for many cases by missing most improtant thing - pipeline. People use them because bash suck and because they want to be full stack.

Besides, Powershell comes with OS.

Re: Linux Bash vs. Windows PowerShell

#36

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. I'll admit to being in the "Bash is what I know, I'll just install WSL/Cygwin/PuTTY on my Windows workstation and be done with it" crowd. PowerShell is on my bucket list of things I need to learn at some point, or at the very lea…

I made a Bash script for HN, and while I’m the furthest thing from an expert in Bash (I’m a newb), I was impressed by a contribution made with a port of the script to Powershell[1]. You can see the same script compared in Bash, Powershell and Python! Prior to this I had never really explored PS, but it is definitely cool Shameless Plug: [1] https://github.com/realrasengan/autobahn

Thanks for posting this, it's interesting to see the same problem solved in 3 languages.

I use Bash for all my scripting needs, on both Windows and Linux - I just can't get over my dislike of Powershell's verbose syntax and Pascal-Snake-Case naming!

But some things are difficult or finicky in Bash; maybe I should stop putting off learning Python...

Re: Linux Bash vs. Windows PowerShell

#37

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…

$ErrorActionPreference = "Stop"

At the top of the script is the closest I fount to `set -e`

Re: Linux Bash vs. Windows PowerShell

#38

This is a pretty poor comparison of the two, especially once it gets into the syntax, of which most of the Bash examples are broken in some way. There’s also a lot of just straight errors, such as mentioning “true” and “false” “values” in Bash, which don’t exist—the userland toolset includes “true” and “false” programs that can be used to inject desired exit code status into some logic flow, but there is no real conc…

Agree.

I have just seen scroll size and imediatelly closed it.

Re: Linux Bash vs. Windows PowerShell

#39

The real difference is: in any reasonable bash script there will be a significant amount of awk, cut, tr and other commands to munge the output of one command into the input expected by the next. In PowerShell that totally goes away.

Better stated like this: in Powershell you do business stuff 99% of the time, in bash you do it 1% of the time and arbitrary text parsing 99% of the time.

To be more evil, your text parsing wont work on all platforms, and you probably didn't od it right or you need to be Reg Exp master which is something I rarely find even in senior devs.

Post reply on HN