I want to pass an entire code block to unshare, but I don't see an option to pass a function directly. I currently have a solution with two files:
File 1: run_with_bash_as_default_shell.sh
sudo unshare -m "$( which run_with_bash_as_default_shell_unsafe.sh )" "$@"
File 2: run_with_bash_as_default_shell_unsafe.sh
sudo mount --bind /bin/bash /bin/sh sudo -u $SUDO_USER "$@" sudo umount /bin/sh
How can I merge these into a single file? I'm nervous about sticking "@" in a larger string, as it may contain lots of special characters, quotes, backslashes, etc.
Better still, I'd rather be able to provide an entire block, something like
# Pseudo-code unshare -m start # Run arbitrary commands in current shell environment unshare stop