Live data from Hacker News

Two Months with Powershell on a Unix

code.joejag.com

21–30 of 113 posts

Re: Two Months with Powershell on a Unix

#21

I am dead serious. Powershell should replace (bash) shell scripting under any Linux. I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead. Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice. Powershell even has a unit test tool called 'pester' which is fun…

I don't know what your native language is, but in English "pester" means to annoy. A negative connotation no matter what.

I don't get the hate on Bash though. It's a natural extension of the command line, and works quite nicely to get a lot done without the overhead. Deployment is a lot easier in my environment (web hosting) because all of the servers are homogenous, and I don't need to worry about any dependencies because I rely mostly on coreutils + grep and awk.

Re: Two Months with Powershell on a Unix

#22
post #8

I've been using Unix for 20+ years, switched to pwsh as my main shell 4 years ago (on both Windows and macOS). Here's my notes: https://github.com/mikemaccana/powershell-profile/ Last few weeks I've been going back to bash, mainly to try out WSL/Ubuntu's defaults, but will probably move to pwsh there too. I like the consistent naming (which means I can guess commands) and avoiding the scraping that's inherent in text…

Hey thanks for this, nushell looks really interesting! I really like the idea of an objective shell but don't like the verbosity of PowerShell inputs. I think if you go through my post history I actually describe wanting something like Nushell, not knowing it existed!

Re: Two Months with Powershell on a Unix

#24
post #6
post #4

Earlier quoted context omitted.

Invoke-WebRequest most certainly runs on linux.

I just attempted to prove you wrong, but it does look like it's fixed. So is creating secure strings. Cool!

Creating secure strings isn't exactly fixed; the type exists but they aren't encrypted in memory on Linux because it doesn't have the DPAPI (Data Protection API) from Windows:

https://github.com/PowerShell/PowerShell/pull/9199

Re: Two Months with Powershell on a Unix

#25

While I really would like UNIX shells to get the ability to pass structured data, one problem is that most shells out AFAIK there don't give the ability to pass structured data natively. For these structured shells(like Powershell, elvish, Nushell) to succeed, they should... * have a spec on how to pass structured data from a native executable (without function calls like 'from-json') * implement some structured data…

That is unlikely to happen in PowerShell because the structured data is .Net objects. If you are writing a C# cmdlet, it runs in the PowerShell executable process. That is, the output is not structured text it's live state, open file handles, methods, in-memory structures, whatever you want. You aren't going to do that from a native command running in a separate process returning data through stdout without serializing it - and then you're back to convertfrom-json as far as it matters.

> For these structured shells(like Powershell, elvish, Nushell) to succeed, they should...

For PowerShell to succeed, Microsoft should rewrite all the GNU coreutils? Did you see the months of outcry when Microsoft used the four characters "curl" in PowerShell? You reckon anyone is going to want unilaterally rewritten coreutils? From Microsoft?

Microsoft should stop on their development of a completely new tool and hobble themselves to the constraints of the stuff they're trying to replace, controlled by people they're in competition with? Unlikely fantasy world.

Re: Two Months with Powershell on a Unix

#27

I am dead serious. Powershell should replace (bash) shell scripting under any Linux. I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead. Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice. Powershell even has a unit test tool called 'pester' which is fun…

> I am dead serious. Powershell should replace (bash) shell scripting under any Linux.

This probably means you don't have a CS background and/or very little experience with linux/scripting/etc and dare I say powershell itself. Scripting in linux/unix/etc is primarily text based whereas powershell is object based ( which is why powershell tends to be slow in comparison ). Also, the only thing going for powershell is it's tie-in with the .Net Framework along with Microsoft based servers ( such as SQL Server ). Like most Microsoft products, it's meant for their environment. There really isn't any real reason for powershell on linux.

> I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead. Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice.

Sounds about right. I can't believe that's what you wrote in support of powershell. Linux, bash, etc was built from the ground up to be command-line friendly. Windows was built to be GUI friendly. But there is a reason why windows administration is viewed as a joke in the tech industry. I guess powershell may seems amazing when going from GUI based administration to actual script based automation/administration.

> Powershell even has a unit test tool called 'pester' which is funny to me because it means 'bully' in my native language.

Yeah, it means bother/annoy in english, but you probably knew that already.

Re: Two Months with Powershell on a Unix

#28
post #17
post #4

Earlier quoted context omitted.

Invoke-WebRequest most certainly runs on linux.

This comment made me go and try out Invoke-WebRequest because I'd forgotten what it was like. Being able to do simple web scraping like this in a "shell" is pretty great: $hn = Invoke-WebRequest https://news.ycombinator.com/ $hn.AllElements | Where {$_.TagName -eq "a" } | Where { $_.Class -eq "StoryLink" } | select "innerHtml"

FWIW, I already have a command line tool that can do that installed in regular Unix: https://github.com/ericchiang/pup The docs even use the same example of scraping HN.

How does Invoke-WebRequest decide if it’s looking at HTML or something else?

Re: Two Months with Powershell on a Unix

#29

I am dead serious. Powershell should replace (bash) shell scripting under any Linux. I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead. Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice. Powershell even has a unit test tool called 'pester' which is fun…

why can't the two coexist? On Linux you can currently choose rather easily between bash, fish, zsh, ash, dash, sh, ksh, csh, tcsh, fish and more. Every script can use the one it wants easily with `#!/usr/bin/env `

If you're arguing that powershell should be the default that's a different argument. sh syntax is still in widespread use because of how portable it is and how widely known it is. It truly is the lingua franca of unixey OSes.

Re: Two Months with Powershell on a Unix

#30

I am dead serious. Powershell should replace (bash) shell scripting under any Linux. I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead. Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice. Powershell even has a unit test tool called 'pester' which is fun…

powershell is ok, I guess, but the core issue is it's over-engineered.

Bash is weird, but it is everywhere and it's simple, and that simplicity is going the be very difficult to replace. How do replace nothing?

I love Python, do switch to it.

( The windows and MS stack is utter balls )

Post reply on HN