In shell scripts one specifies language interpreter on shebang(#!) line. As far as I know, it is recommended to use #!/usr/bin/env bash because env is always located in /usr/bin directory while location of bash may vary from system to system. However, are there any technical differences if bash is started directly with /bin/bash or through env utility? In addition, am I correct that if I do not specify any variables for env, the bash is started in unmodified environment?
What is the difference if I start bash with /bin/bash or /usr/bin/env bash?
bash;environment variables
In one sense, using env could be considered portable in that the path to bash is not relevant (/bin/bash, /usr/bin/bash, /usr/local/bin/bash, ~/bin/bash, or whatever path) because it is specified in the environment. In this way, a script author could make his script easier to run on many different systems.In another sense, using env to find bash or any other shell or command  interpreter is considered a security risk because an unknown binary (malware) might be used to execute the script. In these environments, and sometimes by managerial policy, the path is specified explicitly with a full path: #!/bin/bash.In general, use env unless you know you are writing in one of these environments that scrutinize the minute details of risk.When Ubuntu first started using dash, some time in 2011, many scripts were broken by that action. There was discussion about it on askubuntu.com. Most scripts were written #!/bin/sh which was a link to /bin/bash. The consensus was this: the script writer is responsible for specifying the interpreter. Therefore, if your script should always be invoked with BASH, specify it from the environment. This saves you having to guess the path, which is different on various Unix/Linux systems. In addition, it will work if tomorrow /bin/sh becomes a link to some other shell like /bin/newsh.Another difference is that the env method won't allow the passing of arguments to the interpreter.