Finally, returning to this question, it is quite easy to simply compile (without installing) the bash version (s) . Interestingly, this is how I test Bash 3.2.57:
$ mkdir ~/bash $ cd ~/bash $ wget http://ftp.gnu.org/gnu/bash/bash-3.2.57.tar.gz $ tar xvzf bash-3.2.57.tar.gz $ cd bash-3.2.57 $ ./configure $ make
You now have a Bash 3.2.57 binary that you can run without actually “installing” or changing your normal environment.
To run a shell script for this version:
$ ./bash your_script.sh
To enter a blank interactive prompt :
$ env -i PATH="$PWD:$PATH" ./bash --noprofile --norc bash-3.2$ bash -version GNU bash, version 3.2.57(1)-release (armv7l-unknown-linux-gnu) Copyright (C) 2007 Free Software Foundation, Inc. bash-3.2$
Using env -i , and not just calling ./bash , will lead you to a usually empty environment (run env from within the shell to see what is still set). Updating PATH allows you to invoke bash (e.g. bash -version ) to invoke the local Bash shell, rather than a system-wide installation (but note that this pulls in your entire PATH). Adding --noprofile --norc avoids loading your .bashrc and related scripts.
If you don't want to select any PATH modifications, just do export PATH="$PWD:$PATH" once inside the subshell, and not as part of the env command.
These installation steps are now part of the Docker image , if it is useful to people. I do not necessarily suggest using this image directly, but you can copy it from the Dockerfile. MIT License.
source share