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

You'd think /usr/bin/env would always work, but I've seen this break in production systems where /usr/bin/env is not in the $PATH in situations like cron scripts. It's retarded I know but it does happen.


/usr/bin/env is not in the $PATH

I don't think you mean this. When you specify an absolute name, $PATH is not even in the picture. (I do know that some systems put env in /bin. Those systems are misconfigured.)

Anyway, shebangs are flaky by design. I just run the correct interpreter directly, as in "/path/to/perl -Ilib bin/script.pl". There is no confusion that way.


You're right - I think what he means is that env is not in /usr/bin. This was the case on very old (Red Hat Linux 5.2 back in the late 90s) systems where there was no /usr/bin/env -> /bin/env symlink.


I was bit confused in my description here, sorry. /usr/bin/env existed but when it was run under the cron user's environment it could not locate the interpreter we required and failed silently. The shebang line worked fine under all other users' accounts. Very frustrating. I assume this problem was due to the cron account's $PATH being set up differently somehow. In any case we just went back to explicitly choosing our site-specific interpreter path.

Related pet peeve: people using #!/bin/sh when they really want #!/bin/bash. They are not interchangeable!


Those systems are broken - user binaries are non-critical binaries for everyone. There are more binaries in this location than anywhere else.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: