For portability, you can safely assume that
#!/bin/sh will find a mostly POSIX-compliant shell on any standard Unix or Linux system, but that's really about it.
In FreeBSD, OpenBSD and NetBSD (along with DragonFly, PC-BSD and some other derivatives), bash is located at
/usr/local/bin/bash (if it is installed), so the
/usr/bin/env approach provides portability between Linux and BSD.
Android is not a standard Unix or Linux system. On my not-rooted Android phone, none of
/bin/bash or even
/bin/sh exist, and the system shell is
A shell script that is missing the
#! (shebang) will attempt to run in the shell that called it on some systems, or may use a different default interpreter (
/bin/bash for example), on other systems. And while this may work in Android, it isn't guaranteed to work in other operating systems, where users may elect to use an interactive shell that is not
bash. (I use tcsh in FreeBSD, where it is the default shell, and shebang-less script are interpreted by the calling shell.)
So from where I sit, it looks like it is not possible to create a shell script that is portable between Android and non-Android (Linux or Unix) systems, because Android does things differently.