lua-users home
lua-l archive

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


Hallo,

Tiago Dionizio wrote:

Rici Lake wrote:

Current implementation:

static int io_execute (lua_State *L) {
  lua_pushnumber(L, system(luaL_checkstring(L, 1)));
  return 1;
}

Replace with some variation on:

static int io_execute (lua_State *L) {
  const char *cmd = NULL;
  int status;
  if (!lua_isnoneornil(L, 1)) cmd = luaL_checkstring(L, 1);
  system(cmd);
  lua_pushboolean(L, status == 0);
  lua_pushnumber(L, (lua_Number)status);
  return 2;
}

Where is *status* set int the function above?

   status = system(cmd);

-alex