You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for this? IMO using env is superior:
$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.
vs.
/usr/bin/env bash --version
GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin15.0.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
The reason will be displayed to describe this comment to others. Learn more.
I'm glad someone is paying attention :). I made that change after a short investigation pf which would be best and it seems that using /bin/bash is the safest choice.
Ultimately, I think that on our modern systems, this is really not important, but I'd like to know from the author of that StackOverflow url (which coincidentally is contributor to this project, small world) his opinion.
@Keith-S-Thompson, could you help us find out which is the best for this project?
The reason will be displayed to describe this comment to others. Learn more.
IMHO #!/bin/bash is better, at least partly because it's simpler.
You can reasonably rely on bash being installed as /bin/bash on any modern system (assuming it has bash at all). Using #!/usr/bin/env bash picks up whatever bash happens to be in the user's $PATH. That might be a newer version, but for this particular script that shouldn't make any difference. And if the version of bash matters, #!/usr/bin/env bash isn't likely to help.
There's also no guarantee that env is installed as /usr/bin/env (I've used old systems where it isn't).
Having said that, either one should work, and it probably doesn't make any real difference. In any case, the user can easily edit the script.
61b938b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for this? IMO using env is superior:
vs.
61b938b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad someone is paying attention :). I made that change after a short investigation pf which would be best and it seems that using /bin/bash is the safest choice.
This is one of the resources I found about this:
https://unix.stackexchange.com/questions/29608/why-is-it-better-to-use-usr-bin-env-name-instead-of-path-to-name-as-my/29620#29620
Ultimately, I think that on our modern systems, this is really not important, but I'd like to know from the author of that StackOverflow url (which coincidentally is contributor to this project, small world) his opinion.
@Keith-S-Thompson, could you help us find out which is the best for this project?
61b938b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO
#!/bin/bash
is better, at least partly because it's simpler.You can reasonably rely on
bash
being installed as/bin/bash
on any modern system (assuming it hasbash
at all). Using#!/usr/bin/env bash
picks up whateverbash
happens to be in the user's$PATH
. That might be a newer version, but for this particular script that shouldn't make any difference. And if the version ofbash
matters,#!/usr/bin/env bash
isn't likely to help.There's also no guarantee that
env
is installed as/usr/bin/env
(I've used old systems where it isn't).Having said that, either one should work, and it probably doesn't make any real difference. In any case, the user can easily edit the script.
61b938b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Keith-S-Thompson for your input, that is also my opinion, the only thing that I'm not sure about is in FreeBSD,
bash
's location is not in/bin/
(http://www.cyberciti.biz/faq/freebsd-bash-installation/), but I'm not sure if evenenv
would solve it...61b938b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FreeBSD users can easily create a symlink (
/bin/bash -> /usr/local/bin/bash
) or just edit the#!
.There are gajillions of scripts out there with
#!/usr/bin/bash
shebangs. FreeBSD users presumably have found ways to deal with them.61b938b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True that, thanks again for your input!