News for hackers. Stuff that matters.
Re:Writing Safe Shell Scripts (2019) by Pxtl on Saturday February 01, 2020 @04:07PM (#22213240)
PowerShell, mostly because PowerShell was designed as a mashup of Bash and C#.... And it's kind of a trainwreck in a lot of ways.

It really feels like piping and easy process invocation and compile-time directory awareness wouldn't be massively onerous to add to an existing full-featured programming language so you wouldn't have to sacrifice a good type system and powerful syntax when you want to do scripty things.

Re:Writing Safe Shell Scripts (2019) by chrisfinazzo on Saturday February 01, 2020 @05:42PM (#22213723)
As I understand it, PowerShell came about because porting the standard Linux/Unix utilities to Windows didn't work out.

PowerShell meets both requirements as it's tuned for the Windows environment, but can still play nicely with the rest of the world.

Of course, now that WSL is a thing, it's a real question why someone would want to use PS unless they had no other options.

https://www.heavybit.com/library/podcasts/to-be-continuous/e...

Re:Writing Safe Shell Scripts (2019) by sjy on Sunday February 02, 2020 @02:13AM (#22215635)
PowerShell has real data structures (arrays and hash tables), built-in functional programming tools (Select-Object, ForEach-Object, Where-Object), GUI cmdlets (Out-GridView) and direct access to .NET libraries. It’s a viable tool for many complex tasks where on Unix, you’d need to reach for Python rather than a shell.
Re:Writing Safe Shell Scripts (2019) by vips7L on Sunday February 02, 2020 @11:16AM (#22217618)
>Of course, now that WSL is a thing, it's a real question why someone would want to use PS unless they had no other options.

I use it because I only have to learn one tool, and not a ton of different ones with different UX.

The 'language' is sane, at least to me, as it's object oriented doesn't revolve around parsing strings.

Re:Writing Safe Shell Scripts (2019) by heavyset_go on Sunday February 02, 2020 @05:06AM (#22216181)
Some of the features of PowerShell seem really enticing, and I wish they would make their way over to Unix-like shells. Unfortunately, I don't know how much utility I'd get out of PowerShell on Linux, so I haven't tried it.

edit: your comment inspired me so I installed PowerShell via Snap and am going to give it a go on Linux.

Re:Writing Safe Shell Scripts (2019) by Pxtl on Sunday February 02, 2020 @10:34AM (#22217335)
To me PowerShell mixes easy access to command-line tools and higher-order object-oriented map/filter style functions. The mix between Unix-style piping from command-line tools and modern object-y mapping and filtering can feel like a dream.

That's the good part. The bad part is that it's easily one of the wartiest languages I've ever used, especially as a young language it's really got an inexcusable amount of legacy problems.

A colleague of mine (who also uses it heavily) says "two Googles per line".

Just to get sane parameter and variable checking you have to throw up a bunch of attributes and set a bunch of flags.

Be sure to set up strict mode, use cmdletbinding on your parameter blocks, and set ErrorActionPreference to "stop" in every script you write.

That and the quality of many of the first-party official PowerShell modules is appallingly low by Microsoft standards. The good side is that the .NET framework is accessible so whenever the PowerShell module is failing you, you can drop down into leveraging raw c#-style assemblies, which are much higher quality but they speak PowerShell with a very thick accent.

But I'm using it on Windows, YMMV on Linux.

I'm infatuated with the concept, but the implementation leaves a lot to be desired.

Re:Writing Safe Shell Scripts (2019) by edgyquant on Saturday February 01, 2020 @04:24PM (#22213338)
Right. Powershell is a shell though not a programming language.
Re:Writing Safe Shell Scripts (2019) by plapetomain on Saturday February 01, 2020 @06:28PM (#22213958)
That is false.

Why do you think it is not a programming language?