3

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)

ddnomad
  • 1,978
  • 2
  • 16
  • 31
  • 2
    On the portability front, /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
  • @thrig, on the portability front, there's no guarantee that env will be /usr/bin/env any more than there's a guarantee that bash will be /bin/bash. Misusing env on the shebang line like this doesn't fix the problem, it just shifts it from bash to env. – cas Oct 25 '15 at 06:03
  • 1
    @cas, so what is your point of view? – ddnomad Oct 26 '15 at 08:46

0 Answers0