lua-users home
lua-l archive

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


On Tue, Oct 15, 2013 at 12:26 AM, Benjamin Heath <benjamin.joel.heath@gmail.com> wrote:

The #! line at the beginning of a script needs an absolute path of the program to run this script.

env is a program that runs another program in the path if executed as "env program", and its absolute path is (or should be) /usr/bin/env.

So, put these two facts together as you will often do, and there you have #! /usr/bin/env lua

On Oct 14, 2013 9:20 PM, "Rena" <hyperhacker@gmail.com> wrote:
On Tue, Oct 15, 2013 at 12:07 AM, Benjamin Heath <benjamin.joel.heath@gmail.com> wrote:

Give it a try and learn for yourself, yo.

On Oct 14, 2013 9:04 PM, "Rena" <hyperhacker@gmail.com> wrote:
On Mon, Oct 14, 2013 at 5:20 PM, Elias Barrionovo <elias.tandel@gmail.com> wrote:
On Mon, Oct 14, 2013 at 6:14 PM, Rena <hyperhacker@gmail.com> wrote:
> I see a lot of Lua scripts beginning with:
> #!/usr/bin/env lua
>
> but what's the reason for invoking 'env' and using an absolute path?
>
> --
> Sent from my Game Boy.


Because you don't know if lua is in /bin, /usr/bin, /usr/local/bin,
/home/username/work/totally-not-porn/im-serious/bin/, etc. but env is
usually in /usr/bin and as long as $PATH is right, it doesn't matter
where lua is.

I'm not saying that env *must* be in /usr/bin, but I think it's more
probable for env to be there than lua.

--
NI!

() - www.asciiribbon.org
/\ - ascii ribbon campaign against html e-mail and proprietary attachments


OK, but what's the purpose of 'env'? Can you not write #!lua?

--
Sent from my Game Boy.

Interesting, I thought I'd seen that done before. I wonder why that doesn't work?

--
Sent from my Game Boy.

I see, so env is chosen just because it's usually present and is a way around the "paths must be absolute" restriction without silly side effects?

--
Sent from my Game Boy.