coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: env: add -S option (split string for shebang lines in scripts)


From: Eric Blake
Subject: Re: env: add -S option (split string for shebang lines in scripts)
Date: Tue, 1 May 2018 11:40:31 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 05/01/2018 10:47 AM, Bernhard Voelker wrote:
On Fri, Apr 27, 2018 at 12:57 PM, Eric Blake <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]