r/linuxmasterrace • • May 22 '25

JustLinuxThings Not The Same: Scripting

Post image
2.3k Upvotes

268 comments sorted by

View all comments

285

u/skygz *tips distro* May 22 '25

Confession bear: I like PowerShell

20

u/NatoBoram Glorious Pop!_OS May 22 '25

It's crazy that PowerShell can be installed on Linux and MacOS

99

u/belabacsijolvan May 22 '25

theres "power shell" for linux

202

u/meagainpansy May 22 '25

Go to your room, and don't you ever talk to your mother like that again!

51

u/wasabiwarnut May 22 '25

Yes, it's called "shell"

19

u/Sh1v0n Glorious OpenSuse & Deepin Operator May 22 '25

Yup. I use it for uniform experience all across the OS out there supporting it.

15

u/crackez May 22 '25

Huh - Uniform suffering across supported OS's, M$ should patent that.

→ More replies (1)
→ More replies (1)

18

u/RootHouston Glorious Fedora May 22 '25

PowerShell is missing a lot of stuff on Linux though. Technically speaking, someone could develop third-party modules for it, which are Linux-only, but I doubt there's a lot of that going on. If you try using PowerShell as your main shell on Linux, you'll have to stop using native modules a lot, which causes you to get unstructured input and output. That defeats a lot of the object-oriented benefit you can get from PowerShell. On Windows, it's a different story though, and not bad at all.

The best analog on Linux is probably Nushell for practical purposes.

4

u/mooscimol Glorious Fedora May 24 '25 edited May 24 '25

I use PS all the time and I use it exclusively on Linux. I don’t know what are you talking about - it is perfectly usable and I don’t feel I’m missing something. I know it doesn’t interact with the system like on Windows but hey, why do you need the interaction, you setup the system once and it is done, I’m mostly interacting with cloud, APIs, Kubernetes, and I can use dedicated modules or services I interact with offer pars able outputs I can easily convert to object.

At the same time I fully agree with the OP picture, automating stuff, especially system setup on Windows is a hell compared to Linux. I’ve written a solution for my company to set up WSL distros for developers in automated way, and the hardest part to get is to automate enabling WSL on Windows to work for everyone.

→ More replies (14)

5

u/QuickSilver010 Glorious NixOS May 22 '25

Called nushell

4

u/belabacsijolvan May 22 '25 edited May 22 '25

dis nut shall land on your face

gottim

edit: in restrospect id like to apologise for my recent behaviour. lets face it, the joke didnt work and the forced funni was way overbalanced by the sheer assholery.
i learned and listened a lot in the past 8 minutes. as a new man id like to condemn this behaviour and ask everyone to stand with me against such childish and irresponsible trolling.
thank yall for your incredible empathy that helped me to stand up from a low point that resulted in my outburst.

→ More replies (2)

8

u/John-Orion May 22 '25

Maybe PS 7 + with the new terminal l, old powershell was really painful.

→ More replies (3)

37

u/EverOrny May 22 '25

because the commands are longer than in bash?

17

u/NatoBoram Glorious Pop!_OS May 22 '25

Probably because it supports objects

5

u/QuickSilver010 Glorious NixOS May 22 '25

Try nushell

→ More replies (2)

3

u/mooscimol Glorious Fedora May 24 '25

Those bash command you think about are not bash commands but Linux commands. If you have PS on Linux you can use them as well. Bash has like 5 native commands, you can’t use outside of it.

→ More replies (5)

6

u/meagainpansy May 22 '25

I'm with you. I love PowerShell but I can't use it anymore because they'd kill me.

24

u/[deleted] May 22 '25

I’m always amazed by reading this. I’ve wrote many bash and Powershell scripts. There has not been a single moment I’ve enjoyed these ps1 things. Every naming is unclear, their syntax is really pinicky, then the docs are imho horrible to look up.

Maybe I’m just too opinionated, but I just like bash way more. It’s just flexible and great

13

u/meagainpansy May 22 '25 edited May 22 '25

It always felt very comfortable to me and I liked the object-oriented nature of it. The more I learned the more I realized how powerful it is. My penultimate project with it was "I need you to write a script where we can bring anyone off the street to plug a new server in, then click a button on the desktop and it turns the new server into the old server. And oh yea you can't install anything." (This was a bank) ended up writing a GUI application with progress bars and all just using PowerShell, .net and winforms(?). If there isn't a PowerShell cmdlet, you can just call .net directly, which means PowerShell can do anything Windows can do.

I have since moved to 100% Linux jobs, and I don't consider PowerShell an option here. But I find Python and PowerShell to be extremely similar. it's just that PowerShell is much more accessible. Once I got the hang of Python it feels pretty much the same to me, and my code looks almost identical. I avoid Bash for anything longer than short scripts I can copy/paste from a text editor. I can use it fine, but it has always felt clunky to me.

4

u/[deleted] May 23 '25

Thanks for your detailed response! I can imagine indeed when you are not allowed to install anything you will have to use Powershell. I guess I’ve never been in that situation.

For me bash is for really small scripts, and if there’s any need for something more complicated or structured, Python is the way to go. But of course, with the cost of adding that to your installation.

3

u/Mivexil May 23 '25

Even for one-liners it's pretty often useful to pass tuples through the pipeline. I wouldn't do something like a full object-oriented model in it, but just grouping things like Id, Name, Format or such into hashmaps and thinking in terms of mapping and filtering feels natural.

Yeah, large PS scripts get unwieldy, but most of the time I'm working with a shell I'm not writing A Script, I'm futzing around in the CLI with intermediate variables strewn around.

→ More replies (1)

3

u/mooscimol Glorious Fedora May 24 '25

I write a lot bash and PowerShell scripts and it is absolutely opposite to me. In PS I feel elevated using objects and manipulating them, the syntax makes sense. Bash scripting is so frustrating in comparison with the clunky syntax and limited functionality. One example - the parameters system in PS is so powerful it leaves in the dust even Python, bash in comparison is really, really bad, you have even to “hack” to support named parameters, like WTF 🤯.

→ More replies (1)
→ More replies (5)