Starting scripts with ' /usr/bin/env <whatever>' is rarely useful

5 ingve 1 8/3/2025, 9:30:31 AM utcc.utoronto.ca ↗

Comments (1)

CableNinja · 1h ago
This article made the exact argument for why you SHOULD use /usr/bin/env.

The thing may not be where you expect. And moreso, especially on the python example, virtualenvs are practically a requirement for any slightly advanced python script (anything requiring additional packages), using /usr/bin/python will cause the execution to ignore the virtualenv and result in a failure when the 3rd party packages arent found in the os-level python libraries. Using the env method ensures you are giving a best effort to execute something by a user who may not do things the same way as you. Taking the python example again, are you going to force every user to make their venv at /mycustompath simply because you hardcoded a python shebang? I doubt it, and if you do, no one will use your package, and if they do, youll get the expected complaint.