Re: What happened to 'env'?

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

 



On Thu, Oct 8, 2020 at 12:01 PM Patrick O'Callaghan
<pocallaghan@xxxxxxxxx> wrote:
> On Thu, 2020-10-08 at 08:14 +1100, Cameron Simpson wrote:
>> On 07Oct2020 11:07, Patrick O'Callaghan <pocallaghan@xxxxxxxxx>
>> wrote:
>>> On Tue, 2020-10-06 at 15:45 -0700, ToddAndMargo via users wrote:
>>>>
>>>> I start all my Raku programs with
>>>> 1: #!/usr/bin/env raku
>>>
>>> Why? If you aren't adding options to 'env', surely this is the same
>>> as using '/usr/bin/bash'.
>>
>> No, this is a standard shebang (#!) hack to accomodate differering
>> installation paths. The #! requires a fixed absolute path. So things
>> which are often installed in different places (such as raku above)
>> like /usr/local/bin or /opt/something and accessed via the user's
>> $PATH setting, putting in this line makes the script more portable.
>
> The user's export environment, including the PATH setting, is
> automatically included, even if you have no shebang at all:
>
> $ cat test
> type python3
> echo $PATH
> $ chmod+x test
> $ ./test
> python3 is /usr/bin/python3
> /usr/lib64/qt-3.3/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/poc/.local/bin:/home/poc/bin

You missed "#! requires a fixed absolute path", so you can't use
"#!bash" even though $PATH is set.

Using #!/usr/bin/env bash" supplies "#!" with an absolute path and
runs the script using the first instance of "bash" in $PATH.
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux