The script contained bashisms like substring expansions and a double
quoted tests but still had a /bin/sh shebang, which broke execution on
distros where sh is pointing to `dash` or something other than bash.
Modern Debian is one such example.
Additionally, as the regex pattern was quoted in the original test it
was interpreted literally and not as a regex pattern so the original
logic did not work as intended, even if executed in bash.
The new version keeps the same logic (although without the regex issue)
but implemented in a way that should be compliant with most sh shells,
and perhaps a bit easier to extend with other shells.
The script now depends on sed to replace the bash substring expansion
logic, but sed should be available on almost any system.