Live data from Hacker News

PowerShell vs. Unix shells

stackoverflow.com

61–70 of 84 posts

Re: PowerShell vs. Unix shells

#61
post #36

Earlier quoted context omitted.

> PowerShell is still treated as a second class citizen in the Windows eco-system This is so completely wrong it's not funny. The majority of Microsoft's server GUIs are now built completely on PowerShell. This includes basic products like IIS, Exchange, etc. Where I work, most consultants who implement or maintain these products have learned PowerShell and use it regularly. Windows Server 2012's default option is "h…

Interesting - babarock is incredibly wrong from the windows perspective, but from the unix perspective entirely correct. (I work in IT and handle things on both sides.) Comparatively, the recent and steadily increasing reliance on PS is evidence of microsoft's recognition of the utility of a shell for managing their more complex software. On the other hand, the fact that PS doesn't have it's own readline yet (it's ju…

just try managing AD users in PowerShell - sure its easy once you've written your own custom script or mapped it to a web interface or something, but there's no built in equivalent for adduser or about a billion other basic UNIX commands

It's not that bad. Adding a new AD user is a built-in command. From the docs:

New-ADUser GlenJohn -OtherAttributes @{title="director";mail="glenjohn@fabrikam.com"}

I'm not a UNIX admin; maybe the adduser command is easier. But managing AD stuff in PS is pretty easy (especially if you have to do it in bulk).

Re: PowerShell vs. Unix shells

#62
post #58
post #36

Earlier quoted context omitted.

Interesting - babarock is incredibly wrong from the windows perspective, but from the unix perspective entirely correct. (I work in IT and handle things on both sides.) Comparatively, the recent and steadily increasing reliance on PS is evidence of microsoft's recognition of the utility of a shell for managing their more complex software. On the other hand, the fact that PS doesn't have it's own readline yet (it's ju…

Powershell isn't a wrapper for CMD. It's a separate interface for WMI, COM and .NET.

he's not talking about the powershell engine, he's talking about the frontend repl you interact with

Re: PowerShell vs. Unix shells

#63
post #48
post #16

Powershell creator's deep UNIX background is evident in its design - they have actually fixed many important problems with most UNIX shells. Some of which are: - Moving from a text stream manipulation to structure content. No more worrying if separators need to be escaped within the content each time. - More powerful programming constructs like: Lambda functions, parallel assignments - Signed scripts Even though it m…

I fail to realize why any of these features were "important problems" of Unix shells. Passing byte streams between programs is a very powerful idea and transfers the responsibility of interpreting what the input is to the program parsing it. I realize, from a programmatic point of view, that being able to get a series of objects and to invoke a specific method on them is an intriguing idea, but it breaks the simplici…

a) I fail to realize why any of these features were "important problems" of Unix shells.

b) Passing byte streams between programs is a very powerful idea and transfers the responsibility of interpreting what the input is to the program parsing it.

b) is an important problem. It means that there are zillions of implementations of various parsers. That inefficiency costs money. Worse, not all of them are without bugs. For an example consider the problem of searching by file name in a script. I guesstimate that a large proportion of Linux installations has a buggy version of it somewhere. Doing it reliably (file names can have spaces, may contain control characters or slashes) involves, IIRC, setting $IFS.

Re: PowerShell vs. Unix shells

#64
The fact that not everyone is using fish instead of the ridiculously inflexible, unintuitive and underpowered bash means that the shell mustn't matter that much. I'm just glad I found out about fish.

Re: PowerShell vs. Unix shells

#65
post #50

Earlier quoted context omitted.

One big problem with powershell is that it is not installed on all windows machines by default (I think it is only on some server versions). So you can't just whip up a script and have it run on any machine like you can with bash, which is a first class citizen.

Please, "like you can with the Bourne shell". Scripts that assume you have bash make baby Jesus cry.

Only if baby Jesus is using an open source BSD. Bash is standard on all Linux and OS X installs, and vastly more featureful than the POSIX sh standard. If you're a decent bash hacker and really in a situation where you can't rely on a better scripting runtime to be installed, you'd have to think really hard about whether FreeBSD/OpenBSD is worth the hassle.

Honestly, the BSDs need to get their act together on this and either bash-ify their shells or just use it. Their existing environment is pretty poor.

(I guess an argument could be made that Android is another non-bash environment. But the shell there is so terrible that I literally don't know anyone that's used it for anything in production.)

(Edit: I guess technically I should include Solaris people in the list of bashless victims. But, well, yeah...)

Re: PowerShell vs. Unix shells

#66

Earlier quoted context omitted.

"There is no plausible objective answer to this question, thus its not for StackOverflow." The first half of that sentence is absolutely true. But judging by the enormous number of upvotes, StackOverflow itself (i.e., the people who make it up) disagrees about that second bit. I fall on the side of Stack Overflow at large. Programming is, among other things, an art. Like in any art, there are sometimes situations whe…

>The first half of that sentence is absolutely true. But judging by the enormous number of upvotes, StackOverflow itself (i.e., the people who make it up) disagrees about that second bit. That's a very dangerous thing, look at what happened to Reddit once there was an influx of people from Digg and 4chan. In fact it is critical that a site's focus is maintained in spite of people's opinions. >It's just possible that…

Tens of thousands of views and many answers and comments later, most everything that's happened in response to the question has been edifying.

There's simply no evidence there of a flamewar having been averted. The closest thing I've seen to an unreasonable insult that I've noticed in relation to the topic is an unfounded comparison to 4chan.

Re: PowerShell vs. Unix shells

#67
post #8

The main difference between the two, in my humble opinion, is that PowerShell is a nice (and powerful) addition to a Windows system, whereas the Shell is a fundamental component of Unix. Of course, the two shells may be equivalent in terms of power or number of features, and any contest a la "Can your shell do this?" would be futile. To me, it's a matter of cultural differences. Think of it this way: a shell operates…

the famous McIlroy vs Knuth story http://www.leancrew.com/all-this/2011/12/more-shell-less-egg... here it goes

Re: PowerShell vs. Unix shells

#68
post #54
post #50

Earlier quoted context omitted.

Please, "like you can with the Bourne shell". Scripts that assume you have bash make baby Jesus cry.

Depends on your target. Bash is the LSB shell. If your scripts are only targeting Linux, then you should be able to safely assume bash is there. On Linux, by default, there isn't even a real Bourne shell anyway; it's a symlink to bash. If you're writing cross-platform then yes, sh would be a better target, but a lot of environments are going to be Linux only.

"On Linux, by default, there isn't even a real Bourne shell anyway; it's a symlink to bash."

For a lot of Linux users (Debian/Ubuntu) /bin/sh is a symlink to dash.

Re: PowerShell vs. Unix shells

#69
post #5

PowerShell compared to Cygwin bash, in my experience: * Powershell is more capable than bash, straight up. * bash is easier to use; writing ad-hoc pipes etc. in PowerShell has never seemed pleasant to me, the commands are verbose and the contractions non-obvious; getting help is tedious, and options are often very long. * Object orientation works well when you're dealing with meaningful objects. But often you just wa…

I think this is basically right. PowerShell is what you'd get if you started writing "the perfect shell" from scratch. But comparing to bash in isolation is sort of missing the point. Everything in unix is designed to work in the shell, and that's not true in windows.

So you have tools like ssh and nc and curl at hand, designed to feed each other via pipes and do one thing well. Want to push a file to a server behind a VPN when all I have is ssh access to a host on the network? Trivial. On windows? No clue. It's not a shell problem.

Re: PowerShell vs. Unix shells

#70
post #22

Earlier quoted context omitted.

> You probably heard of the famous McIlroy vs Knuth story (legend?), where a pipe of a few commands turned out to be more efficient than a Knuth data structure. Since very few shell scripts run continuously for long periods of time, it's hard to justify prioritizing runtime efficiency over development time. I remember ActiveState's Perl and the standard Windows version of Python have some API hooks that can be useful…

I know Android is Linux based, and, for background, I'm an experienced Linux user/developer, but have never checked out Android as a Linux till now, though I've heard that phones can be rooted. So my q is: what all can you do with bash on Android - as compared to bash on a desktop or server Linux? Interested to know because I have an Android phone. Do you get all or some of the Linux command-line commands like awk, s…

The base install is very minimal, but you can install a functional environment:

https://play.google.com/store/apps/details?id=com.zpwebsites...

I wouldn't like to run Eclipse on it, but I guess Emacs would run with ease.

Post reply on HN