xopxe / lumen

Lua Multitasking Environment.
Other
153 stars 23 forks source link

fix application exit problem in lua5.1 #13

Closed jaypei closed 9 years ago

jaypei commented 9 years ago

Seems the logic of the expression is wrong.

xopxe commented 9 years ago

I think it is right: the first check is specific for 5.1, where os.execute() returns numeric codes, and after the "or" the check is for later Luas, that return the usual "true or nil,error" pattern, A more verbose version of the logic would be:

if (_VERSION =='Lua 5.1' and ret ~= 0) or ((_VERSION =='Lua 5.2' or _VERSION =='Lua 5.3') and ret ~= true) then

Is it not working on you platform?

jaypei commented 9 years ago

Yes, let us suppose that logic is true, and lua version is 5.1, and the sleep command will return 0, then the expression will equivalent to :

if (true and false or true) then
  os.exit()
end

The application will quit. I think the verbose version is more explicit.

xopxe commented 9 years ago

Actually, you were right and the logic is wrong. Under Lua 5.1, and with a non zero return, the system was exiting. I pushed a fix.