Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable' into merge_stable
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed May 27, 2024
2 parents acd2013 + 82e8e32 commit 3a59a5a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions std/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ static:
*/
bool opBinaryRight(string op : "in")(scope const(char)[] name) @trusted
{
if (name is null)
return false;
version (Posix)
return core.sys.posix.stdlib.getenv(name.tempCString()) !is null;
else version (Windows)
Expand Down Expand Up @@ -444,6 +446,10 @@ private:
// doesn't exist.
void getImpl(scope const(char)[] name, scope void delegate(const(OSChar)[]) @safe sink) @trusted
{
// fix issue https://issues.dlang.org/show_bug.cgi?id=24549
if (name is null)
return sink(null);

version (Windows)
{
// first we ask windows how long the environment variable is,
Expand Down Expand Up @@ -593,6 +599,15 @@ private:
assert("std_process" !in environment);
}

// https://issues.dlang.org/show_bug.cgi?id=24549
@safe unittest
{
import std.exception : assertThrown;
assert(environment.get(null) is null);
assertThrown(environment[null]);
assert(!(null in environment));
}

// =============================================================================
// Functions and classes for process management.
// =============================================================================
Expand Down

0 comments on commit 3a59a5a

Please sign in to comment.