1
0
mirror of https://github.com/janet-lang/janet synced 2026-03-08 00:39:49 +00:00

Merge pull request #1686 from pyrmont/bugfix.windows-empty-env

This commit is contained in:
Calvin Rose
2025-12-14 22:05:03 -06:00
committed by GitHub
2 changed files with 11 additions and 0 deletions

View File

@@ -362,6 +362,8 @@ static EnvBlock os_execute_env(int32_t argc, const Janet *argv) {
janet_buffer_push_bytes(temp, vals, janet_string_length(vals));
janet_buffer_push_u8(temp, '\0');
}
/* Windows environment blocks must be double-NULL terminated */
if (temp->count == 0) janet_buffer_push_u8(temp, '\0');
janet_buffer_push_u8(temp, '\0');
char *ret = janet_smalloc(temp->count);
memcpy(ret, temp->data, temp->count);

View File

@@ -143,6 +143,15 @@
(merge (os/environ) {"HELLO" "WORLD"})))
"os/execute with env")
# os/execute with empty environment
# pr #1686
# native MinGW can't find system DLLs without PATH and so fails
(assert (= (if (and (= :mingw (os/which))
(nil? (os/stat "C:\\windows\\system32\\wineboot.exe")))
-1073741515 0)
(os/execute [;run janet "-e" "(+ 1 2 3)"] :pe {}))
"os/execute with minimal env")
# os/execute regressions
# 427f7c362
(for i 0 10