diff options
| -rw-r--r-- | loslib.c | 18 |
1 files changed, 17 insertions, 1 deletions
| @@ -138,12 +138,28 @@ | |||
| 138 | /* }================================================================== */ | 138 | /* }================================================================== */ |
| 139 | 139 | ||
| 140 | 140 | ||
| 141 | /* | ||
| 142 | ** Despite claiming to be ISO, the C library in some Apple platforms | ||
| 143 | ** does not implement 'system'. | ||
| 144 | */ | ||
| 145 | #if !defined(l_system) && defined(__APPLE__) /* { */ | ||
| 146 | #include "TargetConditionals.h" | ||
| 147 | #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV | ||
| 148 | #define l_system(cmd) ((cmd) == NULL ? 0 : -1) | ||
| 149 | #endif | ||
| 150 | #endif /* } */ | ||
| 151 | |||
| 152 | #if !defined(l_system) | ||
| 153 | #define l_system(cmd) system(cmd) /* default definition */ | ||
| 154 | #endif | ||
| 155 | |||
| 156 | |||
| 141 | 157 | ||
| 142 | static int os_execute (lua_State *L) { | 158 | static int os_execute (lua_State *L) { |
| 143 | const char *cmd = luaL_optstring(L, 1, NULL); | 159 | const char *cmd = luaL_optstring(L, 1, NULL); |
| 144 | int stat; | 160 | int stat; |
| 145 | errno = 0; | 161 | errno = 0; |
| 146 | stat = system(cmd); | 162 | stat = l_system(cmd); |
| 147 | if (cmd != NULL) | 163 | if (cmd != NULL) |
| 148 | return luaL_execresult(L, stat); | 164 | return luaL_execresult(L, stat); |
| 149 | else { | 165 | else { |
