I might be very much mistaken or having missed something in the manual.
But I cannot explain the following behaviour:
Program in file test.lua:
#! /usr/local/bin/lua
if #arg == 0 then
print "call this program with: test 5103"
else
assert (arg[1] == 5103, "arg[1] is not 5103 but " .. arg[1])
end
Its output is when run:
116 ~/Projects/Lua/luaprograms/testing: lua test.lua 5103
lua: test.lua:5: arg[1] is not 5103 but 5103
stack traceback:
[C]: in function 'assert'
test.lua:5: in main chunk
[C]: ?
It must have something to do with arg[1] not being precisely an
integer, because replacing in the test arg[1] by arg[1]-arg[1]%1
passes the assert.
I am really curious when an integer given on the commandline seems to
turn into something not quite integer. Any ideas why? Must this be
considered a bug or a feature.
Hans van der Meer