os.execShellCmd: fixes #10231 (#10232)

Darwin has long deprecated the wait union, but their macros still assume
it unless you define _POSIX_C_SOURCE. This trips up C++ compilers.

This commit duplicates the behavior of WEXITSTATUS when _POSIX_C_SOURCE
is defined.
This commit is contained in:
alaviss
2019-01-08 18:41:15 +07:00
committed by Andreas Rumpf
parent 821920aa39
commit 6737634d88
2 changed files with 16 additions and 1 deletions

View File

@@ -1297,7 +1297,9 @@ proc execShellCmd*(command: string): int {.rtl, extern: "nos$1",
## the process has finished. To execute a program without having a
## shell involved, use the `execProcess` proc of the `osproc`
## module.
when defined(posix):
when defined(macosx):
result = c_system(command) shr 8
elif defined(posix):
result = WEXITSTATUS(c_system(command))
else:
result = c_system(command)

13
tests/stdlib/t10231.nim Normal file
View File

@@ -0,0 +1,13 @@
discard """
target: cpp
action: run
exitcode: 0
"""
import os
if paramCount() == 0:
# main process
doAssert execShellCmd(getAppFilename().quoteShell & " test") == 1
else:
quit 1