Skip to content

Commit af13626

Browse files
danielclarkecapocasa
authored andcommitted
Fixes return values of execCmd on macos (nim-lang#19963)
* Fixes return values of execCmd on macos * update tests to use existing structure Co-authored-by: daniel <[email protected]>
1 parent 506d850 commit af13626

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/pure/osproc.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ elif not defined(useNimRtl):
15231523
header: "<stdlib.h>".}
15241524

15251525
proc execCmd(command: string): int =
1526-
when defined(linux):
1526+
when defined(posix):
15271527
let tmp = csystem(command)
15281528
result = if tmp == -1: tmp else: exitStatusLikeShell(tmp)
15291529
else:

tests/stdlib/tosproc.nim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ when defined(case_testfile): # compiled test file for child process
2929
case arg
3030
of "exit_0":
3131
if true: quit(0)
32+
of "exit_1":
33+
if true: quit(1)
34+
of "exit_2":
35+
if true: quit(2)
36+
of "exit_42":
37+
if true: quit(42)
3238
of "exitnow_139":
3339
if true: exitnow(139)
3440
of "c_exit2_139":
@@ -115,6 +121,13 @@ else: # main driver
115121
runTest("c_exit2_139", 139)
116122
runTest("quit_139", 139)
117123

124+
block execCmdTest:
125+
let output = compileNimProg("-d:release -d:case_testfile", "D20220705T221100")
126+
doAssert execCmd(output & " exit_0") == 0
127+
doAssert execCmd(output & " exit_1") == 1
128+
doAssert execCmd(output & " exit_2") == 2
129+
doAssert execCmd(output & " exit_42") == 42
130+
118131
import std/streams
119132

120133
block execProcessTest:

0 commit comments

Comments
 (0)