POSIX shell scripts shebang #!/bin/sh vs #!/usr/bin/env sh, any difference?
21
votes
2
answers
10306
views
I recently noticed that many scripts are using
/usr/bin/env
in their shebang . I have seen that mainly using Bash and Python , but thus far never in conjunction with POSIX sh
(ash
, dash
,...).
I wonder why, and if my, meant-to-be highly portable, POSIX shell scripts might benefit from the env
approach?
***
Is there a general concensus on whether to use:
- standard:
#!/bin/sh
- environment:
#!/usr/bin/env sh
***
Let me stress this enough:
**I never have seen this with sh
.**
Asked by Vlastimil Burián
(30515 rep)
Feb 27, 2020, 02:08 AM
Last activity: May 3, 2023, 11:09 PM
Last activity: May 3, 2023, 11:09 PM