- cross-posted to:
- programmerhumor@lemmy.ml
- cross-posted to:
- programmerhumor@lemmy.ml
My google history hits for powershell for loop is is in the dozens.
Bash was the first language I learned, got pretty decent at it. Now what happens is I think of a tiny script I need to write, I start writing it in Bash, I have to do string manipulation, I say fuck this shit and rewrite in Python lol
The sad thing is that even chatgpt can’t program in bash. I just want a simple script and every single time it just doesn’t work. I always just end up saying “write this in python instead”.
Python’s usually the better choice anyway tbf. I know piping isn’t as good, but there are so many footguns!
Nushell and Fish can be really convenient too.
I used to adhere to sh for an OpenBSD machine but I switched to python, Rust and Go for, even simple things.
The older you get, the more things are like programming in bash.
Meh. I had a bash job for 6 years. I couldn’t forget it if I wanted to. I imagine most people don’t use it enough for it to stick. You get good enough at it, and there’s no need to reach for python.
Je comprend tellement! Je répond en français pour ma première réponse sur Lemmy juste pour voir comment ça va être géré!
I so understand! Answering I. French for my first Lemmy reply just to see how it’s handled.
Realizing now that language selection is mainly for people filtering. It be cool if it auto translated for people that need it.
i used powershell, and even after trying every other shell and as a die hard Linux user I’ve considered going back to powershell cause damn man
I am a huge fan of using PowerShell for scripting on Linux. I use it a ton on Windows already and it allows me to write damn near cross-platform scripts with no extra effort. I still usually use a Bash or Fish shell but for scripting I love being able to utilize powershell.
Yeah. The best way to write any
bash
script is:apt/yum install PowerShell; pwsh script.ps1
to be honest I agree and thought we would be using something more intuitive by now
Everything is text! And different programs output in different styles. And certain programs can only read certain styles. And certain programs can only convert from some into others. And don’t get me started on
IFS
.I think the cool kids are using Nu now
I still have to look up the exact syntax of ifs and whiles.
I’ve coded in bash for a while
No, Makefile syntax is more extreme.
I swapped from Make to Just: https://github.com/casey/just
Way better, IMO. Super simple logic, just as flexible.
I find
Makefile
isn’t too bad, as long as I can stay away fromautomake
andautoreconf
.Sure, but bash is more relatable, I think
I’ve switched to nutshell imo. Bash is in need of a replacement
When I was finishing of my degree at Uni I actually spent a couple of months as an auxiliary teacher giving professional training in Unix, which included teaching people shell script.
Nowadays (granted, almost 3 decades later), I remember almost nothing of shell scripting, even though I’ve stayed on the Technical Career Track doing mostly Programming since.
So that joke is very much me irl.
Ever since I switched to Fish Shell, I’ve had no issues remembering anything. Ported my entire catalogue of custom scripts over to fish and everything became much cleaner. More legible, and less code to accomplish the same things. Easier argument parsing, control structures, everything. Much less error prone IMO.
Highly recommend it. It’s obviously not POSIX or anything, but I find that the cost of installing fish on every machine I own is lower than maintaining POSIX-compliant scripts.
Enjoy your scripting!
I wish I could but since I use bash at work (often on embedded systems so no custom scripts or anything that isn’t source code) I just don’t want to go back and forth between the two.
It’s the default on CachyOS and I’ve been enjoying it. I typically use zsh.
I switched to fish a while back, but haven’t learned how to script in it yet. Sounds like I should learn
I’ve been meaning to check out
fish
. Thanks for the reminder!Happy adventuring! ✨
I love fish but sadly it has no proper equivalent of
set -e
as far as I know.|| return;
in every line is not a solution.If you’re going to write scripts that requires installing software, might as well use something like python though? Most Linux distros ship also ship with python installed
A shell script can be much more agile, potent, and concise, depending on the use case.
E.g. if you want to make a facade (wrapper) around a program, that’s much cleaner in
$SHELL
. All you’re doing is checking which keyword/command the user wanted, and then executing the commands associated with what you want to achieve, like maybe displaying a notification and updating a global environment variable or something.Executing a bunch of commands and chaining their output together in python is surely much more cumbersome than just typing them out next to each other separated by a pipe character. It’s higher-level. 👍
If it’s just text in text out though, sure, mostly equivalent, but for me this is rarely the use case for a script.
I’m not anti bash or fish, I’ve written in both just this week, but if we’re talking about readability/syntax as this post is about, and you want an alternative to bash, I’d say python is a more natural alternative. Fish syntax is still fairly ugly compared to most programming languages in my opinion.
Different strokes for different folks I suppose.
Unironically love powershell
For a defacto windows admin my Powershell skills are…embarrassing lol but I’m getting there!
It seems like it does stuff differently for the sake of it being different.
It’s more like bash did it one way and everyone who came after decided that was terrible and should be done a different way (for good reason).
Looking right at you -eq and your weird ass syntax
if [[ $x -eq $y ]]
You better not look at powershell in that case :p
That was the point where I closed the bash tutorial I was on, and decided to just use python and
subprocess.run()
-eq
Yeah, like infix, so between operands, but dashed like a flag so should come before arguments. Very odd.