diff --git a/Library/Homebrew/PATH.rb b/Library/Homebrew/PATH.rb index f1c0ebb5d49e4240b9493561f836ebad62c3ea22..de7167eb4b1278c0d2116822469df66250b05cc5 100644 --- a/Library/Homebrew/PATH.rb +++ b/Library/Homebrew/PATH.rb @@ -59,6 +59,7 @@ class PATH def existing existing_path = select(&File.method(:directory?)) + # return nil instead of empty PATH, to unset environment variables existing_path unless existing_path.empty? end diff --git a/Library/Homebrew/test/PATH_spec.rb b/Library/Homebrew/test/PATH_spec.rb index b20a3d3ac01d21c56e981bc82536ce124f49f858..68233c23c7f3bbf81488fd12b0954de8331e174f 100644 --- a/Library/Homebrew/test/PATH_spec.rb +++ b/Library/Homebrew/test/PATH_spec.rb @@ -107,5 +107,9 @@ describe PATH do expect(path.existing.to_ary).to eq(["/path1"]) expect(path.to_ary).to eq(["/path1", "/path2"]) end + + it "returns nil instead of an empty #{described_class}" do + expect(described_class.new.existing).to be nil + end end end