this post was submitted on 05 Mar 2025
1566 points (99.0% liked)

Programmer Humor

21016 readers
1330 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 29 points 1 day ago (6 children)

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!

[–] [email protected] 2 points 14 hours ago (1 children)

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.

[–] [email protected] 1 points 13 hours ago

Yeah, using one tool and then another one can be confusing at times. 😅

[–] [email protected] 9 points 21 hours ago (1 children)

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

[–] [email protected] 3 points 13 hours ago* (last edited 13 hours ago) (1 children)

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.

[–] [email protected] 1 points 12 hours ago (1 children)

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.

[–] [email protected] 1 points 7 hours ago

Fish syntax is still fairly ugly compared to most programming languages in my opinion.

subprocess.run(["fd", "-t", "d", "some_query"])

vs

fd -t d some_query

Which is cleaner? Not to mention if you want to take the output from the command and pipe it into another one.

It's not about folks with weird opinions or otherwise, it's about use cases. 🙂 I don't think python is any more "natural" than most other imperative languages.

Fish is probably even more natural, actually, due to it being more high level and the legibility of the script is basically dependent on the naming of the commands and options and variables used within it, rather than something else, just like python. They probably have similarly legible keywords. Fish I imagine has fewer, which is a good thing for legibility. A script does a lot more with a lot less, due to the commands themselves doing so much behind the scenes. There's a lot more boilerplate to a "proper" programming language than a scripting language.

But if you want to do something that python is better suited for, like advanced data processing or number crunching, or writing a whole application, then I would say that would be the better choice. It's not about preference for me when it comes to python vs fish, it's about the right tool for the job. But if we're talking about bash vs fish, then I'm picking fish purely by preference. 👍

[–] [email protected] 6 points 21 hours ago* (last edited 7 hours ago) (1 children)

I love fish but sadly it has no proper equivalent of set -e as far as I know.

; or return; in every line is not a solution.

[–] [email protected] 3 points 13 hours ago
[–] [email protected] 2 points 18 hours ago (1 children)

It's the default on CachyOS and I've been enjoying it. I typically use zsh.

[–] [email protected] 1 points 13 hours ago

Yeah I also went bash -> zsh -> fish. Zsh was just too complicated to configure for my taste. Couldn't do it, apart from copy pasting stuff I didn't understand myself, and that just didn't sit right.

[–] [email protected] 1 points 19 hours ago (1 children)

I switched to fish a while back, but haven't learned how to script in it yet. Sounds like I should learn

[–] [email protected] 1 points 13 hours ago

Give it a shot after reading through the manual! (Extremely short compared to bash's!) It's a joy in my opinion. ☺️👌

[–] [email protected] 1 points 20 hours ago (1 children)

I've been meaning to check out fish. Thanks for the reminder!

[–] [email protected] 2 points 13 hours ago

Happy adventuring! ✨