publicvoit,
@publicvoit@graz.social avatar

If "#!/usr/bin/env foo" is the preferred (for portable scripts) in order to find "foo" independent of its path, why isn't the recommended shebang "#!env foo" which would not assume a path for "env" either? 🤔

hal_canary,
@hal_canary@mastodon.sdf.org avatar

@publicvoit

the shebang requires an absolute path, iirc.

publicvoit,
@publicvoit@graz.social avatar

@hal_canary I did not find any source (yet) that confirms this assumption which I also had for a brief second.

publicvoit,
@publicvoit@graz.social avatar

@hal_canary Closest thing here: https://en.wikipedia.org/wiki/Shebang_(Unix)#Syntax#Syntax) "interpreter is a path to an executable program" (no source/quote linked)

HaraldKi,
@HaraldKi@nrw.social avatar

@publicvoit The kernel interpretes shebang and does not search at all, either the path is exact or it fails to start. Once env is up and running, env does the search along PATH to find foo.

polyna,
@polyna@toot.community avatar

deleted_by_author

  • Loading...
  • stphrolland,
    @stphrolland@mathstodon.xyz avatar

    @polyna @publicvoit

    So in fact you want to be sure all those other OSes just dont accept your scripts out of the box ? - Whereas they would have if you used /usr/bin/env foo ?

    I say this because I use everyday such an OS, which I think is 10/15 years in advance on the rest of all others linuxes regarding package management and dependencies

    Honestly, it is just a remark, not shaming, I will no longer think about it in one minute

    polyna,
    @polyna@toot.community avatar

    @stphrolland @publicvoit
    > I use everyday such an OS, which I think is 10/15 years in advance on the rest of all others linuxes regarding package management

    You can just say ‘NixOS’, you know.

    But IIRC, NixOS in its own packages always rewrites the #! line in scripts to point directly to an executable under /nix/store, so what I recommend isn’t really much different from what it is doing natively.

    publicvoit,
    @publicvoit@graz.social avatar

    @polyna @stphrolland Fun fact: my current journey with changing all my is because I started to test . 😉

    benjamineskola,
    @benjamineskola@hachyderm.io avatar

    @publicvoit I had been under the impression that its location was defined by POSIX, like /bin/sh, so didn’t need to be searched. But it seems that’s not true for either one.

    However for Unix systems in the real world, having those two utilities in those locations is so commonplace that it feels a lot safer to rely on it than with, for example, Python or even Bash.

    benjamineskola,
    @benjamineskola@hachyderm.io avatar

    @publicvoit and then again, if the first command in a shebang is not required to be a fully qualified path, then why use env at all?

    If #!env foo works by using path lookup, then #!foo should work for the same reasons.

    publicvoit,
    @publicvoit@graz.social avatar

    @benjamineskola Yes, this is probably the strongest argument in this thread so far.

    c6h12o6,

    @publicvoit Better to have one assumption than several dozens... ;)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux
  • ngwrru68w68
  • DreamBathrooms
  • modclub
  • GTA5RPClips
  • InstantRegret
  • magazineikmin
  • Youngstown
  • thenastyranch
  • rosin
  • slotface
  • mdbf
  • khanakhh
  • kavyap
  • anitta
  • tester
  • normalnudes
  • Leos
  • cisconetworking
  • osvaldo12
  • everett
  • Durango
  • tacticalgear
  • provamag3
  • megavids
  • ethstaker
  • cubers
  • JUstTest
  • lostlight
  • All magazines