Aaron Mulder via plug on 1 Jun 2023 06:44:00 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] zsh: command not found: |
On Wed, May 31, 2023 at 11:19:28PM -0400, JP Vossen via plug wrote:
> On 5/31/23 10:36 PM, Gary Duzan via plug wrote:
> > > I always do #!/bin/sh
> > > But I've seen lots of others use #!/usr/bin/env bash
> > > What's the advantage of the latter?
> >
> > It gets bash from the PATH instead of whatever specific path you
> > specify. If you have a non-standard setup, or if you want to use a
> > different version installed elsewhere, this can be a benefit. It could
> > also be a security issue if you accidentally put something insecure in
> > your PATH and you end up running a worm called "bash" from there. I've
> > seen the end trick most often with python, presumably from the days
> > when it wasn't standard equipment, so you ended up putting it in
> > /usr/local/bin or $HOME/bin or something. My NetBSD systems have it in
> > /usr/pkg/bin.
>
> What Gary said, but also don't use `sh` when you mean `bash`. That used to Just Work on Linux (but not elsewhere), but since about 2016 it's not reliable on Linux either, due to use of `dash` as `sh` instead of the much larger and thus slower `bash`.
>
> I'm torn on the hard-code vs. `env` approach. `env` is more portable, but there are possible path/poisoning issues as noted. `#!/bin/bash` is just easier to type and more familiar. :-)
Another advantage of using the `env` approach with python and perl is
that it lets you use tools like pyenv and plenv to switch the version
of the interpreter you're using without having to change your code or
your system python/perl.
Walt
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug