diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-02-02 13:47:28 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-02-02 13:47:28 -0300 |
| commit | 8c064fdc23bd745bbd3456a58cc9e2521f8e4263 (patch) | |
| tree | 432ab16b342f39fab40e050ff4431fbfc8c60cf2 /loslib.c | |
| parent | 8dea54877a5e7b0a461b076e79fdc8b47d7e39e6 (diff) | |
| parent | cf08915d62e338c987b71c078b148490510e9fe7 (diff) | |
| download | lua-8c064fdc23bd745bbd3456a58cc9e2521f8e4263.tar.gz lua-8c064fdc23bd745bbd3456a58cc9e2521f8e4263.tar.bz2 lua-8c064fdc23bd745bbd3456a58cc9e2521f8e4263.zip | |
Merge branch 'master' into nextversion
Diffstat (limited to 'loslib.c')
| -rw-r--r-- | loslib.c | 11 |
1 files changed, 10 insertions, 1 deletions
| @@ -138,12 +138,21 @@ | |||
| 138 | /* }================================================================== */ | 138 | /* }================================================================== */ |
| 139 | 139 | ||
| 140 | 140 | ||
| 141 | #if !defined(l_system) | ||
| 142 | #if defined(LUA_USE_IOS) | ||
| 143 | /* Despite claiming to be ISO C, iOS does not implement 'system'. */ | ||
| 144 | #define l_system(cmd) ((cmd) == NULL ? 0 : -1) | ||
| 145 | #else | ||
| 146 | #define l_system(cmd) system(cmd) /* default definition */ | ||
| 147 | #endif | ||
| 148 | #endif | ||
| 149 | |||
| 141 | 150 | ||
| 142 | static int os_execute (lua_State *L) { | 151 | static int os_execute (lua_State *L) { |
| 143 | const char *cmd = luaL_optstring(L, 1, NULL); | 152 | const char *cmd = luaL_optstring(L, 1, NULL); |
| 144 | int stat; | 153 | int stat; |
| 145 | errno = 0; | 154 | errno = 0; |
| 146 | stat = system(cmd); | 155 | stat = l_system(cmd); |
| 147 | if (cmd != NULL) | 156 | if (cmd != NULL) |
| 148 | return luaL_execresult(L, stat); | 157 | return luaL_execresult(L, stat); |
| 149 | else { | 158 | else { |
