lua-users home
lua-l archive

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


On Fri, Apr 30, 2010 at 09:58:56AM +0200, steve donovan wrote:
> On Fri, Apr 30, 2010 at 8:09 AM, Stuart P. Bentley
> <stuart@testtrack4.com> wrote:
> > If your script is run in the same place as the application, I've heard
> > Windows replaces ! or !! with the path up to the running executable.
> 
> On Unix, typically you write your Lua script like so and make it executable:
> 
> -- ltest
> #!/usr/local/bin/lua
> print('I am '..arg[0])
> 
> And you get exactly what you need from arg[0]
> 
> ~$ ltest
> I am /home/sdonovan/bin/ltest

I promote the use of this for Unix shell script invocation:

    #!/usr/bin/env lua
    print('I am '..arg[0])

This way, it will find whichever lua is first in your execution path,
and run that.  Other people running your script, which may have their
own version of Lua, will be using theirs instead.  And people who
don't have their own copy of Lua will use the system one at
/usr/bin/lua .

James Graves