8 ms·
The latter, because it simplifies using alternate sh if you need to e.g. create separate execution environments, à la virtualenv in python. In fact that's a go
by masklinn 17y ago
The latter, because it simplifies using alternate sh if you need to e.g. create separate execution environments, à la virtualenv in python.
In fact that's a good example, though it's in python: if you use `#!/usr/bin/python` as your shebang your script will break under virtualenv, whereas if you use `#!/usr/bin/env python` it will work perfectly.
Now /bin/sh is probably a POSIX requirement so it'll always be there and you can always override the shebang with an explicit shell call (or by temporarily rebinding /bin/sh though that one requires root access), but going through env doesn't cost you (as a programmer) more and it simplifies the job of the users (if they need to sandbox your script in some way)
- smanek 17y agoThanks, that makes sense. I suppose I'll use an env shebang from now.