Skip to content

Commit a730144

Browse files
committed
FIX: accept block input to call function on Windows
resolves: Oldes/Rebol-issues#2582
1 parent 56a39e6 commit a730144

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/os/win32/host-lib.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,18 @@ void Dispose_Windows(void);
10071007

10081008
if (call == NULL) {
10091009
/* command in argv */
1010-
goto cleanup; /* NOT IMPLEMENTED*/
1010+
// count the length of the full command line...
1011+
size_t len = 1; // termination byte
1012+
for (int n = 0; n < argc; n++) {
1013+
len += wcslen(argv[n]) + 1;
1014+
}
1015+
cmd = cast(wchar_t*, malloc(len * sizeof(wchar_t)));
1016+
cmd[0] = L'\0';
1017+
// construct the command line
1018+
for (int n = 0; n < argc; n++) {
1019+
wcscat(cmd, argv[n]);
1020+
wcscat(cmd, L" ");
1021+
}
10111022
} else {
10121023
if (flag_shell) {
10131024
// command to cmd.exe needs to be surrounded by quotes to preserve the inner quotes

src/tests/units/call-test.r3

+14-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ rebol-cmd: func[cmd][
1818
call/shell/wait/output/error cmd out-buffer err-buffer
1919
]
2020

21-
===start-group=== "Command-Line Interface"
21+
===start-group=== "Command-Line Interface (/shell)"
2222
;@@ https://github.com/Oldes/Rebol-issues/issues/2228
2323
--test-- "--do"
2424
;@@ https://github.com/Oldes/Rebol-issues/issues/2467
@@ -75,6 +75,19 @@ rebol-cmd: func[cmd][
7575
===end-group===
7676

7777

78+
===start-group=== "Command-Line Interface"
79+
--test-- "Block input"
80+
;@@ https://github.com/Oldes/Rebol-issues/issues/2582
81+
--assert all [
82+
file? try [write %issue-2582.r3 {Rebol [] print now}]
83+
tmp: clear ""
84+
0 = call/wait/output reduce [system/options/boot %issue-2582.r3] tmp
85+
date? transcode/one tmp
86+
]
87+
delete %issue-2582.r3
88+
===end-group===
89+
90+
7891
===start-group=== "Error pipe"
7992
--test-- "User controlled error output"
8093
;@@ https://github.com/Oldes/Rebol-issues/issues/2468

0 commit comments

Comments
 (0)