A short rant about #!/bin/sh

I’m really annoyed by it.

If you pick at random a dozen or so shell scripts in your /usr/bin directory that start with the interpreter designation of


you will find at least a few of them that use Bash-specific syntax (“bashisms”). And often, it is something as stupid as using

[[ "$string1" = "$string2" ]]

in situations where a perfectly valid POSIX command like

[ "$string1" = "$string2" ]

would suffice. People who do that deserve to be devoured by a giant frog-monster.

On a typical Arch/EndeavourOS install, there are dozens of such examples of scripting malpractice.

Why does Arch not have a guideline that requires every script that uses /bin/sh as a command interpreter to contain only POSIX-compliant commands?

If you are going to use Bash-specific syntax, just put #!/bin/bash as the first line of your script and there will be no problem!

It’s so simple, just two little characters: ba.

Now, because of such sloppiness, I can’t use Dash and symlink it to /bin/sh like on Debian or 'Buntu (at least not without editing dozens of shell scripts on every update). Really annoying.



I agree that anything that uses sh as an interpreter should be limited to POSIX compliant syntax for portability. It only works because on Arch sh is a symlink to bash

That being said, if you want your scripts to truly portable it is better to use:

#!/usr/bin/env sh

There is no guarantee that sh is located at /bin/sh


Sure, portability is always a nice thing. But this is much worse than not being portable. I’m talking about shell scripts from the Arch repos that invoke sh to run what are actually Bash scripts.


Jeez, you’re uncompromising :joy:

And indeed - POSIX compliant shell scripts must be kept pure.


I made a short look at almost all EndeavourOS scripts, and none of them used #!/bin/sh, except two files (i3 configs) that were directly copied from elsewhere, and didn’t seem to use any bashisms.

I understand your concern, but I’d say EndeavourOS is not contributing to that sloppiness.


Yes, most, if not all of this sloppiness comes from upstream.

I am considering writing a script that runs through the entire output of pacman -Qlq and checks every shell script with checkbashisms tool, and replaces #!/bin/sh with #!/bin/bash on each one that fails the test.

For some inexplicable reason, I have the urge to use Dash as /bin/sh

1 Like

Hopefully do that in a testing VM only… :wink:

1 Like

You will have to run it after every update…

Why not identify them and then propose the changes to the package maintainers? I know it is a lot more work but it will fix the problem for everyone.

Yes, I would have to run it on every update… Which would probably make updating take a lot longer.

I was considering making a list of the offenders, but I can only identify those which are installed on my machines.

Well, I could go through the Arch repos online and just look for every script, but that’s an incredible amount of work.

You should do that on pacman, then on AUR post all affected packages / files on their forum and tell them how they SUCK :rofl:

Perhaps propose necessary change in…script policy :upside_down_face:

Use a pacman hook for checking?

Isn’t that enough?

Of course not! :astonished:

We must parse all GitHub / GitLab / Private gits around the world and tell each one of them how much they suck as well :frog:

But Arch upstream would be good start :laughing:

@Kresimir Sorry, i couldn’t hold myself :joy:

1 Like

So… after about an hour of running a script which I quickly put together, this is the result:

core/automake 1.16.2-3
core/bash 5.0.018-1
core/cronie 1.5.5-1
extra/dkms 2.8.3-1
core/gettext 0.21-1
extra/git 2.28.0-1
core/groff 1.22.4-3
core/grub 2:2.04-8
core/gzip 1.10-3
core/hdparm 9.58-3
extra/hwloc 2.2.0-1
core/libtool 2.4.6+42+gb88cebd5-14
community/lsb-release 1.4-18
extra/mjpegtools 2.1.0-5
extra/mtools 4.0.24-1
core/openresolv 3.11.0-1
extra/openvpn 2.4.9-2
community/os-prober 1.77-2
extra/texlive-core 2020.55416-1
extra/texlive-pictures 2020.55342-1
core/usbutils 012-2
extra/xdg-utils 1.1.3+19+g9816ebb-1
core/xz 5.2.5-1

There are some 23 packages on my system, many of these from the “core” repo, which ship some 65 scripts with which are identified as POSIX scripts by the file command (and use sh as the command interpreter), but are identified by the checkbashisms utility to contain POSIX non-compliant commands.

In total, some 823 scripts were checked, so the percentage of offending scripts was around 7.9%.

Ironically, a script from the package bash which is used to report bugs in Bash, is one of those offending scripts.

If anyone else wants to do a similar analysis, I’d be very interested in your results.


:rofl: :rofl: :rofl:

1 Like

Jesus…Some of the offenders are let’s say…IRONIC :rofl:

1 Like

Sigh…I bet some of those aren’t Arch packaging issues but upstream issues with the software itself.

For example, the scripts for os-prober appear to come entirely from the debian package. Reporting it to Arch wouldn’t even help.

Which leads to an interesting question, does Debian also use bash for sh? If not, is it an issue with the checking script?

1 Like

This pretty much says no on in arch cares. Or that since it points to bash they don’t want posix compliance

Debian uses Dash as the default system shell (and links it to /bin/sh), and requires all scripts with #!/bin/sh to be POSIX compliant. However, Dash will interpret some (very few) non-POSIX commands.

When it comes to os-prober, Dash will run it just fine, even though it contains the command type which is not POSIX-compliant.

Thus os-prober is probably a bad example, and could be tolerated.

i will asap change that I do not want to fight with that giant frogalike monster
:frog: :japanese_ogre: