Skip to content

tests: Fix hardcoded /bin/bash shebangs

Patrick Steinhardt requested to merge pks-nixos-tests-use-portable-shebang into master

We're using the /bin/bash shebang in many of the scripts we're writing in our test suite. This path is not guaranteed to exist by POSIX though, and it in fact doesn't on NixOS, for example.

Unfortunately, there is no way to make this portable according to the POSIX standard except to rewrite the shebang:

Furthermore, on systems that support executable scripts (the "#!"
construct), it is recommended that applications using executable
scripts install them using getconf PATH to determine the shell
pathname and update the "#!" script appropriately as it is being
installed (for example, with sed). For example:

This is not really practical though. There are two alternatives that are commonly used in practice though:

1. Use `/bin/sh` and stop using Bashisms. This binary really exists
   on virtually every platform, even on NixOS. This would require us
   to port over existing test scripts to be compatible.

2. Use `/usr/bin/env bash`, which resolves the shell via PATH. This
   does not require us to port shell scripts and works in practice.

Convert our test scripts to use the second option, as it is the easier one of both and addresses the underlying issue on NixOS.

Merge request reports