The UNIX / Linux SheBang Line


“Why not use #!/usr/bin/env?”

I’ve actually changed my opinion on this. While using env buys you some portability across operating systems that might put bash and the like into different places, some at /bin/sh or /bin/bash or /usr/bin/bash the reality is that /bin/bash is rather reliable.

More importantly using env causes an extract subprocess to be executed just to find bash at a place that we can reliably know in advance. It’s just not worth the performance hit as small as it is.

The env command has to look through the system to find bash (or whatever) before it can even run the thing. Add this on top of an already ridiculously slow start for interpreted script in Python or Node and you get a very noticeable delay. Considering a lot of these scripts are often chained together in some fashion because of the UNIX philosophy and stuff just gets slow and annoying all around.

Avoid the lag. Just say no to env.