Rant on using bash for scripts
I feel like having a rant on using /bin/bash in scripts so here it is:
DON'T USE /bin/bash IN SHELL SCRIPTS EVER.
If bash must be used for the script use "#!/usr/bin/env bash" otherwise use "#!/bin/sh".
The reason is not everyone has bash installed as /bin/bash where if /bin/sh is not there the admin is asking for punishment.
The env trick works with bash wherever it is installed. eg. FreeBSD packages install bash to /usr/local/bin/bash, NetBSD installs it to /usr/pkg/bin/bash (I think, I don't have a NetBSD system handy).
Perl and Python are the same. There might be a link from /usr/bin/perl to /usr/local/bin/perl in FreeBSD but that's just because there used to be a copy of perl in the base system. There is no such link for python, You need to use "#!/usr/bin/env python".
DON'T USE /bin/bash IN SHELL SCRIPTS EVER.
If bash must be used for the script use "#!/usr/bin/env bash" otherwise use "#!/bin/sh".
The reason is not everyone has bash installed as /bin/bash where if /bin/sh is not there the admin is asking for punishment.
The env trick works with bash wherever it is installed. eg. FreeBSD packages install bash to /usr/local/bin/bash, NetBSD installs it to /usr/pkg/bin/bash (I think, I don't have a NetBSD system handy).
Perl and Python are the same. There might be a link from /usr/bin/perl to /usr/local/bin/perl in FreeBSD but that's just because there used to be a copy of perl in the base system. There is no such link for python, You need to use "#!/usr/bin/env python".
0 Comments:
Post a Comment
<< Home