I have a script that is getting run by a third party environment which is running the script with /bin/sh.Is there a way from within the script that I can force bash to be used instead, for example by wrapping the commands in bash <<EOF  ... EOF, like this?#!/bin/bashbash <<EOFIMPORTS=$(find /home/snowch -type f -name .project)for item in ${IMPORTS[*]};do   IMPORT=$(dirname $item)/   echo $IMPORTdoneEOF
Bad Substition how to force /bin/bash as a shell?
bash
You might use this syntax which doesn't require the $ to be escaped unlike your here document attempt.#!/bin/bashbash -c 'IMPORTS=$(find /tmp/foo -type f -name .project)for item in ${IMPORTS[*]};do   IMPORT=$(dirname $item)/   echo $IMPORTdone'Here is a more robust way (thanks to Gilles' comment suggesting it), that has the advantage to allow single quotes to be present in the embedded script:#!/bin/bashbash <<%EOF%IMPORTS=$(find /tmp/foo -type f -name .project)for item in ${IMPORTS[*]};do   IMPORT=$(dirname $item)/   echo $IMPORTdone%EOF%Note: there is no way to prevent someone to use a different shell than the one specified with the shebang. Writing a portable script (i.e. POSIX) script doesn't guarantee it will work with /bin/sh on every platform as the sandard doesn't mandate the POSIX shell to use this path. 