Supershells were introduced before the release of Bash++ v0.1, and were necessary in order to implement object orientation. Although, I’ve never been proud of the name.

Standard forms of command substitution in Bash execute in subshells, which means that any changes made to the environment are lost when we return. If an object’s method is expected to change the object’s state, it cannot be run in a subshell. So, supershells were introduced very early on to allow us to capture the output of a command sequence while still allowing it to modify the environment.

Bash 5.3 has finally adopted supershells natively as a new form of command substitution. This is a huge step forward. In thinking about how the Bash++ compiler can take advantage of this change, I settled on a new compiler option which was introduced in Bash++ v0.6.0

--target-bash <version>

Until now, the Bash++ compiler has assumed Bash 5.2. Bash 5.3 will probably take a while to become the standard across all systems, so we will continue to default to 5.2. But in the mean-time, how can we take advantage of the native supershell implementation in Bash 5.3?

The answer is the --target-bash compiler option. This option allows you to specify which version of Bash you are targeting, and the compiler will adapt its output accordingly. If the version given is 5.3 or higher, then supershells will compile to use the new native form. If lower than 5.3, the compiler will continue to use our old implementation.

On this note, we’ll be working to adapt other portions of the compiler to be capable of generating code for even older versions of Bash to support a wider range of systems. At the moment, we’re relying on features introduced in Bash 4.0 and 4.1 especially, and we will continue to do so by default. But we’ll be working on supporting, for example, --target-bash 3.2 in the future, which will have to replace those features with alternatives that are compatible with these older versions.

For now, it’s relatively safe to say that all code generated by the Bash++ compiler by default is compatible with Bash 4.1+, and it’s definitively safe to say that all code generated by the Bash++ compiler is compatible with Bash 5.2+.