Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Feb 2017 01:26:05 +0000
From:      Manish Jain <bourne.identity@hotmail.com>
To:        "freebsd@edvax.de" <freebsd@edvax.de>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: Variable assignment in sh
Message-ID:  <VI1PR02MB09748570B8832CAA397D19FFF64D0@VI1PR02MB0974.eurprd02.prod.outlook.com>
In-Reply-To: <20170201014858.eec196d0.freebsd@edvax.de>
References:  <b831bd9e40321e59910ea8913c7a6302.squirrel@webmail.harte-lyne.ca> <20170131161824.a9f1ef46.freebsd@edvax.de> <b553c644fccc211f9658b31cfe65e8a0.squirrel@webmail.harte-lyne.ca> <20170131185103.7f911dfb.freebsd@edvax.de> <5f51e2c3bdb8a20c6a7786c2b345c957.squirrel@webmail.harte-lyne.ca> <alpine.BSF.2.20.1701311445520.54303@wonkity.com> <20170201014858.eec196d0.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help



On 02/01/2017 06:18 AM, Polytropon wrote:
> Additionally, it helps to write portable scripts (across
> different operating systems), not just for FreeBSD systems

A point here for bash scripting. I earlier used to shebang with the path 
to bash :

#!/usr/local/bin/bash

Since my scripts sometimes needed to be ported to Linux and/or Cygwin, I 
often hacked the system with a symlink /bin/bash that pointed to the 
actual bash. Then I would use the symlink path - that worked under both 
FreeBSD and Linux.

But a much better way now exists with env :

#!/usr/bin/env bash

The above shabang always works, no matter what the system, is fully 
portable, and is not too much typing either.


Regards
Manish Jain



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?VI1PR02MB09748570B8832CAA397D19FFF64D0>