I always thought that the
.sh filename extension is a class type extension;
meaning it can be used by any type of shell script that runs on a shell based
on bourne shell. The filename extension was not necessarily meant to be
strictly used with POSIX shells only. The earlier shells started with very
basic features and kept improving.
$() for example was not available before.
What I try to point out is that there is no strict or official rule for this.
Bash, much like Zsh and Ksh may have hugely deviated from the other, more basic
shells, but it still doesn’t mean that scripts that run with them cannot use
.sh after all is generic, much like
It is indeed wise to use
.bash for scripts that rely on the features of Bash
since it adds distinguishability, but it’s still not mandatory or official.
No one can declare it to be like it (or almost close to being like it) when it
isn’t. We try to maintain consistency here.
I do acknowledge its usefulness. Besides, the idea of using the extension is
not new to me. Shell Script Loader does use
.bash for scripts that are meant
to work with Bash. I also thought about renaming my module scripts in PlayShell
when I thought about making it compatible with different types of shells. And
that was in 2006 or 2008.
I however didn’t find much importance in using the extension by default right
away, since I never really used other shells besides Bash. And
adds two characters to filenames. I also thought Bash was the only significant
shell in the Linux world. I found that true, at least before Zsh released 5.0
(or maybe a little earlier) and adapted some important array parameter expansion
syntaxes from Ksh/Bash; and also when only few talked about compatiblity and
But I now start to find it to become more necessary, especially with my publicly shared scripts.
Before I wrote this, I already updated all my shared
scripts to use
.bash as their
filename extension. I also updated the overlay and other stuff that refers to
them. And I already have a development version of PlayShell that already has
every bash-based script renamed to
My final say on this is that it is indeed helpful to use specialized extension
names for shell scripts, especially when they are shared to other people.
However if it’s only for personal use, I say that it’s still up for the user
to decide what would be most comfortable for him/her to use. And if there’s a
crusade to make
.bash an official filename extension for Bash, I wouldn’t be
part of it. Using the filename extension should be nothing more than a good