On 05/01/2018 10:47 AM, Bernhard Voelker wrote:
On Fri, Apr 27, 2018 at 12:57 PM, Eric Blake <[email protected]> wrote:
This is missing support for -P, which is one of the essential features
of FreeBSD env, per their man page:
I can certainly add support "-P" (I'll do it in a separate patch though).
Is "-P" (alternate path) something that is often requested?
It makes reasonable sense: the FreeBSD argument is that if you do
#!/usr/bin/env perl
you are at the mercy of finding perl on the user's current PATH, but if
you do:
#!/usr/bin/env -S -P /usr/bin:/opt/bin:${PATH} perl
you can favor /usr/bin/perl or /opt/bin/perl first regardless of whether
the user looks there normally, and without corrupting the user's own
choice of perl for any child processes within the script.
I do see a lot of questions about passing multiple arguments with
"#!/usr/bin/env",
but I haven't noticed people asking about setting per-script non-standard $PATH
(but without changing the actual $PATH).
Isn't this the regular case with specifying the PATH variable?
env PATH=/some:/path prg
Close, but not quite the same. -P can affect the lookup path without
also leaking that changed lookup to the script itself. You're right
that if you call 'env PATH=...', that env has to look up prg within that
specified PATH rather than the PATH in effect pre-env, but I can see
cases where you want to find the interpreter at a known location but NOT
change the PATH handed off to the final script.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org