dylanaraps / pure-bash-bible

📖 A collection of pure bash alternatives to external processes.
MIT License
36.41k stars 3.27k forks source link

Misleading use of shebang #105

Closed h1z1 closed 3 years ago

h1z1 commented 3 years ago

Just a bit of forewarning with regard to the "recommended" use of shebangs.

# Right:

    #!/usr/bin/env bash

# Less right:

   #!/bin/bash

Using env by default is not a good habit because as you state above:

The former searches the user's PATH to find the bash binary.

You do not WANT bash looking at a users local path for say, system scripts, things meant to be run by root or any other user. To say the latter is bad, is.. well, bad itself.

PATH can be manipulated, a script can be set readonly.

Took an inordinate amount of time to explain this to a junior sysadmin who was adamant every script on a production host should be changed "because".

dylanaraps commented 3 years ago

See: https://github.com/dylanaraps/pure-bash-bible/issues/82