lua-users home
lua-l archive

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


On 14/06/2011 13.49, steve donovan wrote:
Simply this: in Lua 5.1, os.execute() returns the system return code,
which is zero for success. So code that assumes this will have to be
carefully audited.

uh... thanks for pointing that out. Does ~= 0 necessarily mean failure, outside of system commands? Perhaps it's just foggy memory, but I seem to remember writing some tools that returned information that way.

What about returning true,'exit',0 in case of success? This way, the third value will give the actual value returned by the os, whatever that will be, and it could make backwards compatibility simpler:
 _, _, os_retval = os.execute(cmd)

(apologies if this all makes little sense, I'm a bit disconnected from Lua development in this period; I hope not for long)

--
  Enrico