diff options
| author | Markus Reiter | 2017-04-28 11:22:23 +0200 | 
|---|---|---|
| committer | Markus Reiter | 2017-04-30 21:11:28 +0200 | 
| commit | e70f2ec33233422b70db047338aa85d9e2088042 (patch) | |
| tree | 659d606769cd2b4b3fe66da9ad3fcbd7fa29d9d9 /Library/Homebrew | |
| parent | 0bb9b4918e5068ab58799da11e758dbbe6592953 (diff) | |
| download | brew-e70f2ec33233422b70db047338aa85d9e2088042.tar.bz2 | |
Make sure duplicates are remove from `PATH`.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/PATH.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/test/PATH_spec.rb | 12 | 
2 files changed, 14 insertions, 2 deletions
| diff --git a/Library/Homebrew/PATH.rb b/Library/Homebrew/PATH.rb index 9ee621285..6c5cd9e41 100644 --- a/Library/Homebrew/PATH.rb +++ b/Library/Homebrew/PATH.rb @@ -4,12 +4,12 @@ class PATH    end    def prepend(*paths) -    @paths.unshift(*parse(*paths)) +    @paths = parse(*paths, *@paths)      self    end    def append(*paths) -    @paths.concat(parse(*paths)) +    @paths = parse(*@paths, *paths)      self    end diff --git a/Library/Homebrew/test/PATH_spec.rb b/Library/Homebrew/test/PATH_spec.rb index d1b1f074d..7e42670f2 100644 --- a/Library/Homebrew/test/PATH_spec.rb +++ b/Library/Homebrew/test/PATH_spec.rb @@ -13,6 +13,10 @@ describe PATH do      it "splits an existing PATH" do        expect(described_class.new("/path1:/path2")).to eq(["/path1", "/path2"])      end + +    it "removes duplicates" do +      expect(described_class.new("/path1", "/path1")).to eq("/path1") +    end    end    describe "#to_ary" do @@ -31,12 +35,20 @@ describe PATH do      it "prepends a path to a PATH" do        expect(described_class.new("/path1").prepend("/path2").to_str).to eq("/path2:/path1")      end + +    it "removes duplicates" do +      expect(described_class.new("/path1").prepend("/path1").to_str).to eq("/path1") +    end    end    describe "#append" do      it "prepends a path to a PATH" do        expect(described_class.new("/path1").append("/path2").to_str).to eq("/path1:/path2")      end + +    it "removes duplicates" do +      expect(described_class.new("/path1").append("/path1").to_str).to eq("/path1") +    end    end    describe "#validate" do | 
