Skip to content

Commit 6191f4f

Browse files
committed
FIX: allow getting empty environmental string on Posix platforms
1 parent 35ff54a commit 6191f4f

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/os/posix/host-lib.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ int pipe2(int pipefd[2], int flags); //to avoid "implicit-function-declaration"
474474
if (value == 0) return 0;
475475

476476
len = LEN_STR(value);
477-
if (len == 0) return -1; // shouldn't have saved an empty env string
477+
//if (len == 0) return -1; // shouldn't have saved an empty env string
478478

479479
if (len + 1 > valsize) {
480480
return len + 1;

src/tests/run-tests.r3

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dt [ ;- delta time
3737
%units/mold-test.r3
3838
%units/money-test.r3
3939
%units/object-test.r3
40+
%units/os-test.r3
4041
%units/pair-test.r3
4142
%units/parse-test.r3
4243
%units/percent-test.r3

src/tests/units/os-test.r3

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Rebol [
2+
Title: "Rebol OS test script"
3+
Author: "Oldes"
4+
File: %os-test.r3
5+
Tabs: 4
6+
Needs: [%../quick-test-module.r3]
7+
]
8+
9+
~~~start-file~~~ "OS"
10+
11+
===start-group=== "set-env / get-env"
12+
--test-- "env-1"
13+
--assert "hello" = set-env 'test-temp "hello"
14+
--assert "hello" = get-env 'test-temp
15+
--test-- "env-2"
16+
--assert "" = set-env 'test-temp ""
17+
--assert "" = get-env 'test-temp
18+
--test-- "env-3"
19+
--assert none? set-env 'test-temp none
20+
--assert none? get-env 'test-temp
21+
22+
===end-group===
23+
24+
25+
~~~end-file~~~

0 commit comments

Comments
 (0)