I'm trying to write some provisioning shell scripts for Vagrant dev environment. I'm used to start bash scripts as follows
#! /bin/bash
But after surfing through some git repos I found out that in most cases guys use
#! /usr/bin/env bash
So the question is: what the difference and what is the most decent way to start a bash script? (any alternatives are also appreciated)
/bin/bash
will not exist on a stock BSD system, as for example on OpenBSD, if bash is actually installed, it will be under/usr/local/bin
, unless the admin has taken additional steps to symlink it to other locations. – thrig Oct 06 '15 at 21:59/usr/bin/env
any more than there's a guarantee thatbash
will be/bin/bash
. Misusingenv
on the shebang line like this doesn't fix the problem, it just shifts it frombash
toenv
. – cas Oct 25 '15 at 06:03