Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think many lightweight container images don’t have /usr/bin/env for example but they all have /bin/sh. Which I think is the best option for portability.

/usr/bin/env is not POSIX anymore than /bin/bash etc.



http://manpag.es/RHEL6/1p+env

Mentions that the env command is POSIX, but it doesn't mention the absolute path. Are you saying that /use/bin/env is not POSIX because there is no guarantee that it will be available at that particular path?


Interestingly enough, not even the path of /bin/sh is guarenteed. From the POSIX:

> Applications should note that the standard PATH to the shell cannot be assumed to be either /bin/sh or /usr/bin/sh, and should be determined by interrogation of the PATH returned by getconf PATH, ensuring that the returned pathname is an absolute pathname and not a shell built-in.

EDIT: I wondered what POSIX recommended to do for any use of the shebang and this is what I found:

> Furthermore, on systems that support executable scripts (the "#!" construct), it is recommended that applications using executable scripts install them using getconf PATH to determine the shell pathname and update the "#!" script appropriately as it is being installed (for example, with sed).

Wow.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: