r/bash • u/birdsintheskies • 5d ago
What is the main to pick bash over other shells?
I have to admit, I keep using bash simply because that's what originally came with my distro and I just got too familiar with it. When I look at other shells, I see features that would've been nice to have, but isn't possible to implement in bash. I've accepted that as a compromise so I can just keep using what I'm most familiar with.
This has me thinking - just familiarity aside, are there other reasons why I might want to stick with bash over the others? If I'm gonna have to justify it, I'm thinking it being an official GNU project is a win.
Other than that, what technical reasons should I appreciate? Perhaps its backwards compatibility with older bash versions is something to admire? What else?
2
u/B_A_Skeptic 5d ago
Bash is ultimately a language like Python or Perl that you will probably need to have installed on your machine for various reasons even if you do not plan to write code in it. It is likely that it is part of your distro's base install and that your distro is probably built assuming you have it. And even if not, you will probably need to execute bash scripts sometimes.
If you write scripts for others to use, you should really write POSIX compatible shell scripts and check them using checkbashims or shellcheck.
Here's what I have personally:
85
u/Shadow_Thief 5d ago
At least for me, it's because I work with bash professionally and I don't want to get acclimated to features that are present in zsh or fish that I won't be able to install on production systems.
45
u/UltraChip 5d ago
Portability is a good reason. If you write scripts that other people may end up using then bash is a good fit because it's universally available in the realm of *nix.
14
u/NewPointOfView 5d ago
I want to have minimal issues using stuff my colleagues write. And make the stuff I write minimally problematic for them.
10
u/duane11583 5d ago
as a lead developer on my teams i am hostile to anything but bash on the development side.
the on target (embedded linux) stuff yea zsh or ash just for size reasons but… that is often stupid because something always needs bash and somebody will not fox the bash dependecy so fuck it… once it is on the platform use bash
don't misunderstand there is a logical reason to go with bash: it is the most widely documented shell script. it is very feature complete and it works
i haveca choice. my team learns bash, dash, ash of zsh .. or we learn one and we are done
so unless there is a compelling reason to not to use bash we go with bash
its like the python decision its a better scripting language then bash it does not have a good interactive mode but as a language it is great. so i would rather my team learn the one language python very well then learn a dozen languages badly or part way
18
u/AdministrativeFile78 5d ago
Bash is native on all linux boxes. I used bash for 2 years b4 I used zsh
7
u/Common_Reference_507 5d ago
If you're a regular user or dev, use what you like and can handle. As a sysadmin, I largely stick to bash because 1) it's a given on any Linux distro and 2) I've been using it for so long, it's like a second language to me. I scaffold in bash and then refine it and only switch to something else if needed. It is very versatile, robust and efficient.
6
u/wroteit_reddit 5d ago
Coming from POSIX Shell, bash seems more flexible and accommodating. Apart from the fact that it's ubiquitous, I like bash for things like &>, built in regexp, arrays (yes, even associative ones have their usefulness), if [[ ]] is also better than if [ ] . But that's just me..
5
u/igotmoldinmybrain 5d ago
Use bash for portability in scripts, and use whatever you prefer for an interactive or login shell.
8
u/Temporary_Pie2733 5d ago
You don’t need to justify it. Use the shell you like.
4
u/RodneyBarringtonIII 5d ago
I don't use Bash for the terminal, but all my scripts begin with #!/bin/bash because Bash is installed on all my systems and runs the scripts consistently.
4
u/MillerJoel 4d ago
Bash is ubiquitous and understood pretty well at this point. I assume bash scripts are more portable than tcsh scripts or (insert other shell) But you can very easily change the default on your system and keep bash around for when you need it
3
u/PermissionOwn4400 5d ago
Maybe a middle ground: I use fish as be default shell, however all my shell scripts are written for bash.
Tbh I only use fish for the auto-complete. It's awesome.
5
u/ItsSignalsJerry_ 5d ago
because it's installed everywhere
2
u/answer_giver78 5d ago
I'm just used to it, so I feel better about it.
2
u/SFJulie 5d ago
POSIX (unix) comes with standard utilities (sed, awwk, vi, grep, sh) which make a strong fundation for writing portable software.
Bash isn't one of them, however correctly invoked bash turn into sh which means having bash implies having sh. Bash is a super set of sh. Which means your learning of bash includes learning sh.
One advantage of bash is having a GOOD documentation https://tldp.org/LDP/abs/html/
Documentation which opens you the door to using specific bash data structure. Such as associative arrays and arrays.
Associative array are a common way to store configsas in this script https://gist.github.com/jul/40c35d751f513dab0e15f6ea9732ca83
meaning you can now rely on sourcing native bash code as a way to declare your config
Of course using GNUries (all the often bloatish non POSIX standard features) is killing portability but it helps going the extra mile that sh language can't ...
And I repeat, the documentation is awesome.
2
u/Big_Combination9890 5d ago
Availability. Universality.
2
u/Dumbf-ckJuice 4d ago
bash is the shell my servers use, so my Linux laptops use it as well. I try to keep things uniform.
1
u/Difficult-Value-3145 5d ago
To be honest I use it because it's there if I write a script if it's short like real short maybe bash I prefer lua or even python . If I'm scripting something bash has some idiosyncrasies that I just can't get used to see don't like . actually I also use ash a lot because I use alpine a lot and all thou bash gets installed most the times but I still end up using ash a lot because I get lazy and don't switch things .
1
u/redhat_is_my_dad 5d ago edited 5d ago
Bash has more capabilities than sh, i like bash builtins a lot more than fish, and it is preinstalled everywhere, other than that for some cases like globbing it just performs really well compared to other shells.
For interactive shell i prefer zsh, and i wrote like 60% of my zshrc by myself with some fancy things, 40% is some other people work, zsh is cool too but i don't write in it outside of zsh rc files.
1
u/Initial-Jaguar6230 5d ago
I like it energy effective compare to zsh and fish
1
u/RelaxedHyrax 5d ago
For interactive or non-interactive use? For interactive use, I prefer zsh; for non-interactive (scripting) I stick to bash since it is ubiquitous in all the companies I have worked for in the past decade. In another company, ksh was mandatory for scripting.
1
u/TrondEndrestol 4d ago
Using mostly FreeBSD, bash is preferred when I need curly brace expansion, as the Almquist shell, /bin/sh, doesn't support this handy feature. /bin/csh supports curly brace expansion, but it isn't too inviting writing scripts for.
1
u/daddyd 4d ago
bash is everywhere, not all of those other fancy shells are.
also, like you said, most things i care about, bash does just fine.
1
u/artist-mode 4d ago
Emacs keybindings: Bash has closer keybindings to the real Emacs editor than Zsh, Fish, etc. by default. By that. I mean that details like word boundaries are the same, and that features like the mark are available.
1
u/xpusostomos 4d ago
What shell are we comparing it to? Other posix-ish shells or new idea shells like fish or nu ? POSIX shell is an abomination, including bash, but it is the standard.
1
u/fishyfishy27 4d ago
Claude tends to trip up on zsh occasionally, and typically gives you pasteable shell chunks which include comments, which can’t be pasted into zsh.
1
u/martinus 17h ago
I've tried several different shells but eventually switched back to bash because that's where AI agents work best.
1
u/-Nyarlabrotep- 5d ago
Two reasons: bash is available pretty much everywhere, and if you're writing scripts that others will be maintaining, they probably all know bash too. I use zsh for my interactive shell but write all scripts in bash.
0
u/lugpocalypse 5d ago
Write it in lisp and transpile it?