Skip to content

Commit

Permalink
FIX: allow getting empty environmental string on Posix platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jul 21, 2020
1 parent 35ff54a commit 6191f4f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/os/posix/host-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ int pipe2(int pipefd[2], int flags); //to avoid "implicit-function-declaration"
if (value == 0) return 0;

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

if (len + 1 > valsize) {
return len + 1;
Expand Down
1 change: 1 addition & 0 deletions src/tests/run-tests.r3
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dt [ ;- delta time
%units/mold-test.r3
%units/money-test.r3
%units/object-test.r3
%units/os-test.r3
%units/pair-test.r3
%units/parse-test.r3
%units/percent-test.r3
Expand Down
25 changes: 25 additions & 0 deletions src/tests/units/os-test.r3
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Rebol [
Title: "Rebol OS test script"
Author: "Oldes"
File: %os-test.r3
Tabs: 4
Needs: [%../quick-test-module.r3]
]

~~~start-file~~~ "OS"

===start-group=== "set-env / get-env"
--test-- "env-1"
--assert "hello" = set-env 'test-temp "hello"
--assert "hello" = get-env 'test-temp
--test-- "env-2"
--assert "" = set-env 'test-temp ""
--assert "" = get-env 'test-temp
--test-- "env-3"
--assert none? set-env 'test-temp none
--assert none? get-env 'test-temp

===end-group===


~~~end-file~~~

0 comments on commit 6191f4f

Please sign in to comment.