fidian/multishell
A testing image designed to experiment with different versions of shell interpreters.
869
This image contains MANY different versions of common shells. At last count, it is over 600. This is useful to see if a script operates as expected on different platforms, with different versions of the same shell, or with different shells entirely. There is nearly every version of Apple's Bash, Bash, Dash, Fish, Sash, Tcsh, and Zsh. Each of those have their internal version or the source code version appended (eg. bash-4.3.2
). In addition, symbolic links are created and they point to the most recent version of that series, so bash-4.3
points the the latest bash-r.3.x
version.
This build includes all of the shells from the following subprojects:
ksh
sash
Is that too many shells? Concerned about the amount of consumed space? If so, there's a Multishell-Small image available that contains a hand-curated list that represents a fair cross-section of the shells.
Let's take a look at all of the shells.
$ docker run -it --rm fidian/multishell
root@b4afcd2cf5c8:/# ls /usr/local/bin
apple-bash-103 bash-4.0.11 bash-4.3.44 tcsh-6.04
apple-bash-103.50 bash-4.0.12 bash-4.3.45 tcsh-6.04.00
apple-bash-103.50.1 bash-4.0.13 bash-4.3.46 tcsh-6.05
.... hundreds of shells ...
Ok, so there's lots of shells. We can now show off differences in how the shells process commands. Run this in your Docker container.
root@b4afcd2cf5c8:/# cat > test_script
IFS=z
a=(one two three)
a=("${a[@]:1}")
set | grep ^a=
At the end, press enter and then press control-D to end the cat
command. Now we've created test_script
. It defines an array a
and the array contains three elements (one
, two
, and three
). The next line is supposed to expand to every element after the first, so it should be identical to a=(two three)
, but that's not the case for different versions of Bash. The last line simply writes the value of the array.
root@b4afcd2cf5c8:/# bash-3.2.57 test_script
a=([0]="two three")
root@b4afcd2cf5c8:/# bash-4.0.0-pre1 test_script
a=([0]="two" [1]="three")
This works when we want to test only a couple versions. To automate testing, you can run any script against a whole series of shells. First, we need to modify the script so it tests exactly what we want and returns a proper status code.
root@b4afcd2cf5c8:/# cat > test_script
IFS=z
a=(one two three)
a=("${a[@]:1}")
[[ ${#a[@]} -eq 2 ]]
Again, press control-D to end the cat
command. The only change that was made is to the last line. If we have two array elements, the test passes. If we have one, the test fails. Now, to run this against every version of Bash, we run one command.
root@b4afcd2cf5c8:/# run-script-againt-shells bash test_script
... lots of lines trimmed ...
bash-3.2.55: FAIL
bash-3.2.56: FAIL
bash-3.2.57: FAIL
bash-4.0.0: pass
bash-4.0.0-rc1: pass
bash-4.0.1: pass
... many more lines trimmed ...
Perfect! It really did get fixed in 4.0.0-rc1.
docker pull fidian/multishell