Powershell is cross platform too these days, which makes this kind of a moot point.
Powershell is cross platform too these days, which makes this kind of a moot point.
Powershell on Linux isn’t worth is because I end up having to parse everything as text anyway, completely negating any benefit I can come up with. It doesn’t feel as natural as the *nix tools to me.
So I'm curious what kinds of things you mean when you say you have to parse everything as text anyway. I suspect you've needed to a lot more of those kinds of tasks than I have.
What I mean by parsing as text was more about actual commands.
I wasn't expecting 1:1, but as an example, let's say I wanted to get a list of local users on a machine.
On Windows I can use "Get-LocalUser". It returns an object with properties you can filter, output with a format, etc. Basic stuff that saves me doing any thinking. I like that. It's amazing how column titles add to the user friendliness.
On Linux, Get-LocalUser doesn't exist, so I could run something like "getent passwd". It's only option is to return a screen of text. There's no structure yet, just lines and colons. Now I can (even though I shouldn't) grab fields with cut, or awk, and filter with grep, and maybe output something pretty at the end with column. What does the 5th column mean again?
So on the Linux side, I've never been very motivated to use it, since I often have to fall back to old ways anyway.
One thing that was nice about my adopting Powershell as my daily shell is that for the most part, I could just use the same shell utilities as usual:
getent passwd | cut -f6 -d':' | sort | uniq -c
Like, there's no problem running that in powershell. I know people have talked about "mixing" strings and objects but, I have to say that for me I've rarely run into a problem with it?As you learn you can do a little more. Maybe you learn that group (group-object) can be used instead of the two commands at the end:
getent passwd | cut -f6 -d':' | group
And for me, the nice thing is that when you learn something like that, it's leverageable across all your cases. You learned something about your tool, not just about the passwd file.Is this better than bash? I don't think it's worse:
getent passwd | %{ ($_ -split ':')[5] } | group
But then you might notice that your data is a CSV (C for colon in this case) and you might leverage some of the CSV-handling which works well in Powershell: getent passwd | convertfrom-csv -del ':' -h 'user','pwd','uid','gid','comment','home','shell' | group -prop 'shell'
Now you're cooking with structured data again. I think familiarity makes this kind of thing come naturally. And since these commands are pretty discoverable, because they're more consistent, and tab-completion and command-line editing are so much better than bash. It's easy to see how the above can be made terser by stashing it into utility function or a hashtable in your profile (e.g. so you could do "getent passwd | fields passwd" or something like that.Now, I'm not going to tell someone it's worth the growing pains and adjustments to switch. It's like switching keyboard layouts. And matters of taste might turn you off, understandable. But for me there have been real benefits, and on its merits, I do think it makes a better shell. And it would be nice (from my perspective) if the community did some more work around these use cases and making them nicer for people.
Sorry, trying to be funny, not dismissive.
I think shells in general could use some rethinking, considering they still feel pretty 80s.
Familiarity (or my lack of) is likely a big reason I’ll miss the obvious.
Zsh fills in many of the same checkboxes while being similar enough you don’t lose muscle memory when you find a bash shell somewhere.
Maybe someday something else will take over. Windows has the advantage there, for sure.
I do wonder about the muscle memory thing. I think having to create scripts in bash keeps my hand in enough that I won't lose it too badly. At least I hope so. I compared switching shells to switching keyboard layouts; something I also did, and something where it's been some effort to retain enough muscle memory to not completely flail when presented with another computer.
But it's true that, like, you get help with Powershell but that might not matter on a system where you wouldn't choose to install man pages or something.
It’s also really slow for text processing, borderline unusable
Does it at least integrate with DBus a bit?
I also have no desire to use Powershell when I don't need to.
What’s the difference between installing git bash on windows and installing powershell on Mac/Linux? I would argue that there is none.
And obviously it’s fine that you don’t want to use PowerShell, I don’t want to use it either. But personally I also dislike git bash on windows. It doesn’t feel like it belongs there, just like powershell doesn’t really belong on Linux/Mac.
If I had to write a build script for all three platforms I would just write them for their native environments. I wouldn’t be all that willing to add another tool to be installed just to save myself the effort of simple build script.
For my use case, I don't see the need to bend my builds around Powershell just to use Powershell. This plays into my other point about not wanting to dig into Windows fundamentals when I don't need to.
> If I had to write a build script for all three platforms I would just write them for their native environments. I wouldn’t be all that willing to add another tool to be installed just to save myself the effort of simple build script.
This was my initial approach, but it became too much work to maintain separate build systems, especially when it came to making changes over time. One change becomes three, along with three new opportunities for things to break in three separate ways.
For what I'm doing, moving to Unix-y toolchains simplified builds and made it much easier to reason about it.
You picking one OS that you’re okay with modifying but the other one you’re not. If we inversed that preference and said that I’m willing to modify my Linux containers but unwilling to install software on my Windows VM, the logic is the same.
By the way, Microsoft publishes Linux images that already have PowerShell pre-installed.
https://learn.microsoft.com/en-us/powershell/scripting/insta...
So, technically, if your build scripts were 100% PowerShell you could have it where both Windows VMs and Linux docker images could be unmodified.
Since your build scripts sound overly complex, they could possibly benefit from a scripting language that’s got support for objects and object data pipelines, more advanced error handling, and more advanced object parsing than tools like sed and awk.
Just playing “devil’s advocate” here, the logic checks out.
Big, big difference. My Windows laptop is basically a terminal to the Linux development server. I can install anything (within reason) on Windows, can't install shit on the Linux server unless I beg the IT admin for days and eventually he just says "no". He did install the "mc" (Midnight Commander) utility on it though and made my life like 100x easier. If MC were bundled with git bash, that would be something I would cheer for.
And yeah, I use git bash too on Windows. For accessing the Linux shell through ssh when I remotely connect to the server and for convenience locally. Main workhorse are the "less" and "grep" utilities to examine logs. What am I goint to use otherwise, Notepad?
Microsoft actually gives you SSH without the need to install git bash.
https://learn.microsoft.com/en-us/windows/terminal/tutorials...
grep on windows is Select-String
https://learn.microsoft.com/en-us/powershell/module/microsof...
More command on windows:
https://learn.microsoft.com/en-us/windows-server/administrat...
What will you use to view logs, Notepad? Well, you could use the #1 most popular text editor that Microsoft happens to develop, VSCode. Or a wide array of Windows GUI software that isn’t available on Linux, like Notepad++.
The fact that your IT department has those specific policies in place and is inflexible with your developers isn’t really relevant to this discussion. The truth is that if you wanted PowerShell on Linux it is trivial to install. Microsoft even publishes Linux images that already include PowerShell.
With bash, you only need to learn 10 or 20 short commands and a few flag variants, over a gently long period of time. Then you're all set for 97% of cases likely to be encountered.
A lot of people (myself included) tend to underestimate the power of the heavily optimized GNU utilities and the ability to manipulate them with bash.
[0] It was two lines for readability. It could have easily been a single line.
So I get why unfamiliarity would make it not worth it to switch from whatever shell you prefer, but I don't think I can see your point about flags.