lua-users home
lua-l archive

Re: What has happened to arg?

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


On 5/06/2013, at 3:07 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> It is 05:00 in my timezone. My head probably is not working.
> 
> I can't figure out this:
> 
> …/latest$ src/lua
> Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
>> print(arg)
> nil
> 
> It is the very latest Lua 5.2.2, just downloaded from lua.org.
> 
> Surely `arg` should be a table, in which arg[0]="lua" etc.?
arg doesn't seem to be available to the command-line. Page 8 of PiL(2nd ed I'm afraid) says "A *script* can retrieve its arguments...".
Given this test.lua:
print(_VERSION)
print(arg[-1], arg[0])
I get:
$ ./lua test.lua 
Lua 5.2
./lua	test.lua
My 5.2 was compiled with LUA_COMPAT_ALL off.

AltStyle によって変換されたページ (->オリジナル) /