* s/exitStatus(...)/exitStatusLikeShell(...)/ * fix #10273 execShellCmd now returns nonzero when child exits with signal * test case for #10249 and explanation for the bug * fix test failure * add tests/nim.cfg
This commit is contained in:
parent
f5cc2e2de5
commit
9af85fb69f
8 changed files with 148 additions and 41 deletions
|
|
@ -1287,6 +1287,17 @@ proc moveFile*(source, dest: string) {.rtl, extern: "nos$1",
|
|||
discard tryRemoveFile(dest)
|
||||
raise
|
||||
|
||||
proc exitStatusLikeShell*(status: cint): cint =
|
||||
## converts exit code from `c_system` into a shell exit code
|
||||
when defined(posix) and not weirdTarget:
|
||||
if WIFSIGNALED(status):
|
||||
# like the shell!
|
||||
128 + WTERMSIG(status)
|
||||
else:
|
||||
WEXITSTATUS(status)
|
||||
else:
|
||||
status
|
||||
|
||||
proc execShellCmd*(command: string): int {.rtl, extern: "nos$1",
|
||||
tags: [ExecIOEffect], noNimScript.} =
|
||||
## Executes a `shell command`:idx:.
|
||||
|
|
@ -1295,14 +1306,8 @@ proc execShellCmd*(command: string): int {.rtl, extern: "nos$1",
|
|||
## line arguments given to program. The proc returns the error code
|
||||
## of the shell when it has finished. The proc does not return until
|
||||
## the process has finished. To execute a program without having a
|
||||
## shell involved, use the `execProcess` proc of the `osproc`
|
||||
## module.
|
||||
when defined(macosx):
|
||||
result = c_system(command) shr 8
|
||||
elif defined(posix):
|
||||
result = WEXITSTATUS(c_system(command))
|
||||
else:
|
||||
result = c_system(command)
|
||||
## shell involved, use `osproc.execProcess`.
|
||||
result = exitStatusLikeShell(c_system(command))
|
||||
|
||||
# Templates for filtering directories and files
|
||||
when defined(windows) and not weirdTarget:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue