How can I force a specific binary to be used when executing a bash script?
I have a bash script which uses the "php" binary.
There are several php versions on my computer. The main php binary, as configured via the PATH variable, is not the one to be used in this case.
Normally the script will be executed like this:
./script.sh
I need something like this:
php=/usr/bin/php ./script.sh
NOTE: It is not an option to temporary change the PATH variable just for this command, because this will affect other dependencies.
Hardcoding it in the script is also not an option, because the script is used by multiple people. So when other people execute the script it should just use the main php binary as specified in the PATH variable.
I don't want it to be accessible via a variable. I actually want to specify the exact location to look for the binary. Just like it would normally do by using PATH, only now for one single binary with the absolute path to it. If this script calls another script, that second script also needs to use that php version. –
php
being used for? Can't you enforce a version in that script? – goldilocks Oct 18 '13 at 14:18php
variable before calling the script like you did? – Joseph R. Oct 18 '13 at 16:21