diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/BaseConstructor.cs b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/BaseConstructor.cs
index f179d49..2e8e824 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/BaseConstructor.cs
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/BaseConstructor.cs
@@ -13,7 +13,7 @@
  *
  * Copyright (C) 2007 Ola Bini <ola@ologix.com>
  * Copyright (c) Microsoft Corporation.
- * 
+ *
  ***** END LICENSE BLOCK *****/
 
 using System;
@@ -38,8 +38,8 @@ namespace IronRuby.StandardLibrary.Yaml {
     public class BaseConstructor : IEnumerable<object> {
         private readonly static Dictionary<string, YamlConstructor> _yamlConstructors = new Dictionary<string, YamlConstructor>();
         private readonly static Dictionary<string, YamlMultiConstructor> _yamlMultiConstructors = new Dictionary<string, YamlMultiConstructor>();
-        private readonly static Dictionary<string, Regex> _yamlMultiRegexps = new Dictionary<string, Regex>();        
-        
+        private readonly static Dictionary<string, Regex> _yamlMultiRegexps = new Dictionary<string, Regex>();
+
         private readonly Dictionary<Node, List<RecursiveFixer>>/*!*/ _recursiveObjects = new Dictionary<Node, List<RecursiveFixer>>();
         private readonly NodeProvider/*!*/ _nodeProvider;
         private readonly RubyGlobalScope/*!*/ _globalScope;
@@ -168,7 +168,7 @@ namespace IronRuby.StandardLibrary.Yaml {
             if (node is ScalarNode) {
                 return ConstructScalar(node);
             } else if (node is SequenceNode) {
-                return ConstructSequence(node);            
+                return ConstructSequence(node);
             } else if (node is MappingNode) {
                 return ConstructMapping(node);
             } else {
@@ -193,7 +193,7 @@ namespace IronRuby.StandardLibrary.Yaml {
                 throw new ConstructorException("expected a scalar or mapping node, but found: " + node);
             }
             return scalar.Value;
-        }        
+        }
 
         public object/*!*/ ConstructPrivateType(Node node) {
             object val = null;
@@ -206,7 +206,7 @@ namespace IronRuby.StandardLibrary.Yaml {
                 val = ConstructSequence(node);
             } else {
                 throw new ConstructorException("unexpected node type: " + node);
-            }            
+            }
             return new PrivateType(node.Tag,val);
         }
 
@@ -282,7 +282,7 @@ namespace IronRuby.StandardLibrary.Yaml {
             if (null != merge) {
                 merge.AddLast(mapping);
                 mapping = new Hash(_globalScope.Context);
-                foreach (Hash m in merge) {                    
+                foreach (Hash m in merge) {
                     foreach (KeyValuePair<object, object> e in m) {
                         IDictionaryOps.SetElement(_globalScope.Context, mapping, e.Key, e.Value);
                     }
@@ -403,14 +403,14 @@ namespace IronRuby.StandardLibrary.Yaml {
         }
 
         private static Regex _timestampRegexp;
-        
-        private static Regex TimestampRegex { 
-            get { 
+
+        private static Regex TimestampRegex {
+            get {
                 return _timestampRegexp ?? (_timestampRegexp = new Regex(@"
                     ^[ \t]*
 
                     (                               # Year
-                        -? 
+                        -?
                         [0-9][0-9][0-9][0-9]
                     )
                     -
@@ -424,7 +424,7 @@ namespace IronRuby.StandardLibrary.Yaml {
                             |
                             [ \t]+
                         )
-                    
+
                         ([0-9][0-9]?)               # Hour
                         :
                         ([0-9][0-9])                # Minute
@@ -449,16 +449,16 @@ namespace IronRuby.StandardLibrary.Yaml {
                         )
                     )?
 
-                    [ \t]*$", 
+                    [ \t]*$",
                     RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant));
             }
         }
 
         private static Regex _ymdRegex;
-        
+
         internal static Regex YmdRegex {
             get {
-                return _ymdRegex ?? (_ymdRegex = 
+                return _ymdRegex ?? (_ymdRegex =
                     new Regex("^(-?[0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)$", RegexOptions.CultureInvariant)
                 );
             }
@@ -658,7 +658,7 @@ namespace IronRuby.StandardLibrary.Yaml {
 
                 foreach (KeyValuePair<object, object> e in ctor.ConstructMapping(node)) {
                     string name = e.Key.ToString();
-                    name = "" + name[0].ToUpperInvariant() + name.Substring(1);
+                    name = "" + name[0].ToString().ToUpperInvariant() + name.Substring(1);
                     PropertyInfo prop = type.GetProperty(name);
 
                     prop.SetValue(result, Convert.ChangeType(e.Value, prop.PropertyType), null);
@@ -673,3 +673,4 @@ namespace IronRuby.StandardLibrary.Yaml {
         #endregion
     }
 }
+
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/default.mspec b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/default.mspec
index fd1cef1..c7cdb27 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/default.mspec
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/default.mspec
@@ -14,16 +14,21 @@ if engine == 'ironruby'
   $" << "resolv.rb"
 end
 class MSpecScript
+  if RUBY_PLATFORM =~ /(mswin|mingw|bccwin|wince)/i
+    ir_cmd = 'ir.cmd'
+  else
+    ir_cmd = 'ir.sh'
+  end
   # The default implementation to run the specs.
-  set :target, "#{ENV['MERLIN_ROOT']}\\Test\\Scripts\\ir.cmd"
+  set :target, File.join("#{ENV['MERLIN_ROOT']}","Test","Scripts",ir_cmd)
   # config[:prefix] must be set before filtered is used
-  set :prefix, "#{ENV['MERLIN_ROOT']}\\..\\External.LCA_RESTRICTED\\Languages\\IronRuby\\mspec\\rubyspec"
+  set :prefix, File.join("#{ENV['MERLIN_ROOT']}","..","External.LCA_RESTRICTED","Languages","IronRuby","mspec","rubyspec")
   
   set :core1sub1,filtered("core","[ac-i]")
   set :core1sub2,[ #want to keep basicobject out of the 1.8 list
-    "core\\bignum",
-    "core\\binding",
-    "core\\builtin_constants"
+    File.join("core","bignum"),
+    File.join("core","binding"),
+    File.join("core","builtin_constants")
   ]
   set :core2, filtered("core", "[j-z]").reject{|el| el =~ /thread/i}
   set :lang, [
@@ -36,20 +41,20 @@ class MSpecScript
   set :lib2, filtered("library", "[p-z]").reject {|el| el =~ /prime/}
   #.NET interop
   set :netinterop, [
-    "..\\..\\..\\..\\..\\Main\\Languages\\Ruby\\Tests\\Interop\\net"
+    File.join("..","..","..","..","..","Main","Languages","Ruby","Tests","Interop","net")
     ]
   
   set :netcli, [
-    "..\\..\\..\\..\\..\\Main\\Languages\\Ruby\\Tests\\Interop\\cli"
+    File.join("..","..","..","..","..","Main","Languages","Ruby","Tests","Interop","cli")
     ]
 
   set :cominterop, [
-    "..\\..\\..\\..\\..\\Main\\Languages\\Ruby\\Tests\\Interop\\com"
+    File.join("..","..","..","..","..","Main","Languages","Ruby","Tests","Interop","com")
     ]
   
   set :thread, [
-    "core\\thread",
-    "core\\threadgroup"
+    File.join("core","thread"),
+    File.join("core","threadgroup")
     ]
 
   #combination tasks
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mkspec b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mkspec
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mkspec.bat b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mkspec.bat
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-ci b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-ci
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-ci.bat b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-ci.bat
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-run b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-run
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-run.bat b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-run.bat
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-tag b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-tag
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-tag.bat b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec-tag.bat
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec.bat b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/mspec.bat
old mode 100644
new mode 100755
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getgrent_spec.rb b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getgrent_spec.rb
index 9d63a4e..c4961f2 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getgrent_spec.rb
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getgrent_spec.rb
@@ -5,3 +5,42 @@ require 'etc'
 describe "Etc.getgrent" do
   it_behaves_like(:etc_on_windows, :getgrent)
 end
+
+platform_is_not :windows do
+  describe "Etc.group" do
+
+    before(:all) do
+      @etc_group = `cat /etc/group`.chomp.split("\n").
+        map { |s| s.split(':') }.
+        map { |e| Struct::Group.new(e[0],e[1],e[2].to_i,e[3].to_a) }
+    end
+
+    before(:each) do
+      Etc.setgrent
+    end
+
+    it "should return an instance of Struct::Group" do
+      Etc.getgrent.should be_an_instance_of(Struct::Group)
+    end
+
+    it "should return the first entry from /etc/group on the first call" do
+      expected = @etc_group.first
+      actual = Etc.getgrent
+      actual.should == expected
+    end
+
+    it "should return the second entry from /etc/group on the second call" do
+      expected = @etc_group.at(1)
+      Etc.getgrent
+      actual = Etc.getgrent
+      actual.should == expected
+    end
+
+    it "should return nil once all entries are retrieved" do
+      (1..@etc_group.length).each { Etc.getgrent }
+      actual = Etc.getgrent
+      actual.should be_nil
+    end
+
+  end
+end
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getlogin_spec.rb b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getlogin_spec.rb
index 6835e70..36e5712 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getlogin_spec.rb
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getlogin_spec.rb
@@ -2,6 +2,10 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require 'etc'
 
 describe "Etc.getlogin" do
+  it "should return a String" do
+    Etc.getlogin.should be_an_instance_of(String)
+  end
+
   it "returns the name of the user who runs this process" do
     Etc.getlogin.should == username
   end
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getpwent_spec.rb b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getpwent_spec.rb
index e2141d4..8c8faca 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getpwent_spec.rb
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getpwent_spec.rb
@@ -2,6 +2,47 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/shared/windows'
 require 'etc'
 
-describe "Etc.getpwent" do
-  it_behaves_like(:etc_on_windows, :getpwent)
+platform_is :windows do
+  describe "Etc.getpwent" do
+    it_behaves_like(:etc_on_windows, :getpwent)
+  end
+end
+
+platform_is_not :windows do
+  describe "Etc.getpwent" do
+
+    before(:all) do
+      @etc_passwd = `cat /etc/passwd`.chomp.split("\n").
+        map { |s| s.split(':') }.
+        map { |e| Struct::Passwd.new(e[0],e[1],e[2].to_i,e[3].to_i,e[4],e[5],e[6]) }
+    end
+
+    before(:each) do
+      Etc.setpwent
+    end
+
+    it "should return an instance of Struct::Passwd" do
+      Etc.getpwent.should be_an_instance_of(Struct::Passwd)
+    end
+
+    it "should return the first entry from /etc/passwd on the first call" do
+      expected = @etc_passwd.first
+      actual = Etc.getpwent
+      actual.should == expected
+    end
+
+    it "should return the second entry from /etc/passwd on the second call" do
+      expected = @etc_passwd.at(1)
+      Etc.getpwent
+      actual = Etc.getpwent
+      actual.should == expected
+    end
+
+    it "should return nil once all entries are retrieved" do
+      (1..@etc_passwd.length).each { Etc.getpwent }
+      actual = Etc.getpwent
+      actual.should be_nil
+    end
+
+  end
 end
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getpwuid_spec.rb b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getpwuid_spec.rb
index 03b71b6..3729d24 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getpwuid_spec.rb
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/getpwuid_spec.rb
@@ -34,6 +34,10 @@ platform_is_not :windows do
       end
     end
 
+    it "raises if the passwd entry does not exist" do
+      lambda { Etc.getpwuid(9876)}.should raise_error(ArgumentError)
+    end
+
     it "only accepts integers as argument" do
       lambda {
         Etc.getpwuid("foo")
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/group_spec.rb b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/group_spec.rb
index 01ac143..c61388f 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/group_spec.rb
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/group_spec.rb
@@ -2,6 +2,71 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/shared/windows'
 require 'etc'
 
-describe "Etc.group" do
-  it_behaves_like(:etc_on_windows, :group)
+platform_is :windows do
+  describe "Etc.group" do
+    it_behaves_like(:etc_on_windows, :group)
+  end
+end
+
+platform_is_not :windows do
+  describe "Etc.group" do
+
+    before(:all) do
+      @etc_group = `cat /etc/group`.chomp.split("\n").
+        map { |s| s.split(':') }.
+        map { |e| Struct::Group.new(e[0],e[1],e[2].to_i,e[3].to_a) }
+    end
+
+    before(:each) do
+      Etc.setgrent
+    end
+
+    it "should return an instance of Struct::Group" do
+      gr = Etc.group
+      gr.is_a?(Struct::Group).should == true
+    end
+
+    it "should return the first entry from /etc/group on the first call without a passed block" do
+      expected = @etc_group.first
+      gr = Etc.group
+      gr.gid.should == expected.gid
+    end
+
+    it "should return the second entry from /etc/group on the second call without a passed block" do
+      expected = @etc_group.at(1)
+      Etc.group
+      gr = Etc.group
+      gr.gid.should == expected.gid
+    end
+
+    it "should return nil once all entries are retrieved without a passed block" do
+      (1..@etc_group.length).each { Etc.group }
+      gr = Etc.group
+      gr.should be_nil
+    end
+
+    it "should loop through all the entries when a block is passed" do
+      expected = @etc_group.length
+      actual = 0
+      Etc.group { |gr| actual += 1 }
+      actual.should == expected
+    end
+
+    it "should reset the file for reading when a block is passed" do
+      expected = @etc_group.first
+      Etc.group
+      actual = nil
+      Etc.group { |gr| actual = gr if actual.nil? }
+      actual.gid.should == expected.gid
+    end
+
+    it "should reset the file for reading again after a block is passed" do
+      expected = @etc_group.at(1)
+      last = nil
+      Etc.group { |gr| last = gr unless gr.nil? }
+      actual = Etc.group
+      actual.gid.should == expected.gid
+    end
+
+  end
 end
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/passwd_spec.rb b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/passwd_spec.rb
index bd6645d..32931ab 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/passwd_spec.rb
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/passwd_spec.rb
@@ -2,6 +2,72 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/shared/windows'
 require 'etc'
 
-describe "Etc.passwd" do
-  it_behaves_like(:etc_on_windows, :passwd)
+platform_is :windows do
+  describe "Etc.passwd" do
+    it_behaves_like(:etc_on_windows, :passwd)
+  end
+end
+
+platform_is_not :windows do
+  describe "Etc.passwd" do
+
+    before(:all) do
+      @etc_passwd = `cat /etc/passwd`.chomp.split("\n").
+        map { |s| s.split(':') }.
+        map { |e| Struct::Passwd.new(e[0],e[1],e[2].to_i,e[3].to_i,e[4],e[5],e[6]) }
+    end
+
+    before(:each) do
+      Etc.setpwent
+    end
+
+    it "should return an instance of Struct::Passwd" do
+      pw = Etc.passwd
+      pw.is_a?(Struct::Passwd).should == true
+    end
+
+    it "should return the first entry from /etc/passwd on the first call without a passed block" do
+      expected = @etc_passwd.first
+      pw = Etc.passwd
+      pw.uid.should == expected.uid
+    end
+
+    it "should return the second entry from /etc/passwd on the second call without a passed block" do
+      expected = @etc_passwd.at(1)
+      Etc.passwd
+      pw = Etc.passwd
+      pw.uid.should == expected.uid
+    end
+
+    it "should return nil once all entries are retrieved without a passed block" do
+      (1..@etc_passwd.length).each { Etc.passwd }
+      pw = Etc.passwd
+      pw.should be_nil
+    end
+
+    it "should loop through all the entries when a block is passed" do
+      expected = @etc_passwd.length
+      actual = 0
+      Etc.passwd { |pw| actual += 1 }
+      actual.should == expected
+    end
+
+    it "should reset the file for reading when a block is passed" do
+      expected = @etc_passwd.first
+      Etc.passwd
+      actual = nil
+      Etc.passwd { |pw| actual = pw if actual.nil? }
+      actual.uid.should == expected.uid
+    end
+
+    it "should reset the file for reading again after a block is passed" do
+      expected = @etc_passwd.at(1)
+      last = nil
+      Etc.passwd { |pw| last = pw unless pw.nil? }
+      actual = Etc.passwd
+      actual.uid.should == expected.uid
+      last.uid.should == @etc_passwd.last.uid
+    end
+
+  end
 end
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/setgrent_spec.rb b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/setgrent_spec.rb
index 6491c8b..e32f31a 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/setgrent_spec.rb
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/setgrent_spec.rb
@@ -2,6 +2,28 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/shared/windows'
 require 'etc'
 
-describe "Etc.setgrent" do
-  it_behaves_like(:etc_on_windows, :setgrent)
+platform_is :windows do
+  describe "Etc.setgrent" do
+    it_behaves_like(:etc_on_windows, :setgrent)
+  end
+end
+
+platform_is_not :windows do
+  describe "Etc.setgrent" do
+
+    before(:all) do
+      @etc_group = `cat /etc/group`.chomp.split("\n").
+        map { |s| s.split(':') }.
+        map { |e| Struct::Group.new(e[0],e[1],e[2].to_i,e[3].to_a) }
+    end
+
+    it "should reset the file pointer on etc/group" do
+      expected = @etc_group.first
+      Etc.getgrent
+      Etc.setgrent
+      gr = Etc.getgrent
+      gr.should == expected
+    end
+
+  end
 end
diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/setpwent_spec.rb b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/setpwent_spec.rb
index 4b1e606..eeafaff 100644
--- a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/setpwent_spec.rb
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/etc/setpwent_spec.rb
@@ -2,6 +2,27 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/shared/windows'
 require 'etc'
 
-describe "Etc.setpwent" do
-  it_behaves_like(:etc_on_windows, :setpwent)
+platform_is :windows do
+  describe "Etc.setpwent" do
+    it_behaves_like(:etc_on_windows, :setpwent)
+  end
+end
+
+platform_is_not :windows do
+  describe "Etc.setpwent" do
+
+    before(:all) do
+      @etc_passwd = `cat /etc/passwd`.chomp.split("\n").
+        map { |s| s.split(':') }.
+        map { |e| Struct::Passwd.new(e[0],e[1],e[2].to_i,e[3].to_i,e[4],e[5],e[6]) }
+    end
+
+    it "should reset the file pointer for etc/passwd" do
+      expected = @etc_passwd.first
+      Etc.getpwent
+      Etc.setpwent
+      pw = Etc.getpwent
+      pw.should == expected
+    end
+  end
 end
diff --git a/Merlin/Main/Languages/Ruby/Libs/etc.rb b/Merlin/Main/Languages/Ruby/Libs/etc.rb
index 9b4babb..91101d5 100644
--- a/Merlin/Main/Languages/Ruby/Libs/etc.rb
+++ b/Merlin/Main/Languages/Ruby/Libs/etc.rb
@@ -13,20 +13,139 @@
 #
 # ****************************************************************************
 
-class Etc
+module Etc
+
+  Struct.new('Passwd', :name, :passwd, :uid, :gid, :gecos, :dir, :shell)
+  Struct.new('Group', :name, :passwd, :gid, :mem)
+
   class << self
-    def getlogin
-      ENV['USERNAME']
-    end
+    platform = System::PlatformID
+    case System::Environment.OSVersion.Platform
+    when platform.Win32S, platform.WinCE, platform.Win32Windows, platform.Win32NT:
+      def getlogin
+        ENV['USERNAME']
+      end
     
-    def endgrent(*args)
-      nil
-    end
+      def endgrent(*args)
+        nil
+      end
+
+      [:endpwent, :getgrent, :getgrgid, :getgrnam, :getpwent, 
+       :getpwnam, :getpwuid, :group, :passwd, :setgrent,
+       :setpwent].each do |method|
+        alias_method method, :endgrent
+      end
+    else
+      load_assembly 'Mono.Posix'
+ 
+      def endgrent
+        Mono::Unix::Native::Syscall.endgrent
+        nil
+      end
+
+      def endpwent
+        Mono::Unix::Native::Syscall.endpwent
+        nil
+      end
+
+      def getgrent
+        result = Mono::Unix::Native::Syscall.getgrent
+        to_group(result)
+      end
+
+      def getgrgid(p1)
+        result = Mono::Unix::Native::Syscall.getgrgid(p1)
+        to_group(result)
+      end
+
+      def getgrnam(p1)
+        result = Mono::Unix::Native::Syscall.getgrnam(p1.to_clr_string)
+        to_group(result)
+      end
+
+      def getlogin
+        result = Mono::Unix::Native::Syscall.getlogin
+        String.new(result)
+      end
+
+      def getpwent
+        result = Mono::Unix::Native::Syscall.getpwent
+        to_passwd(result)
+      end
+
+      def getpwnam(p1)
+        result = Mono::Unix::Native::Syscall.getpwnam(p1.to_clr_string)
+        to_passwd(result)
+      end
+
+      def getpwuid(p1)
+        result = Mono::Unix::Native::Syscall.getpwuid(p1)
+        to_passwd(result)
+      end
+
+     def group
+        if block_given? then
+          # Reset groups
+          setgrent
+
+          # Get the first group, then loop until the last, yielding the current group.
+          grp = getgrent
+          until grp.nil?
+            yield grp unless grp.nil?
+            grp = getgrent
+          end
+
+          # Reset groups.
+          setgrent
+        end
+        getgrent
+      end
+
+      def passwd
+        if block_given? then
+          # Reset passwd
+          setpwent
+
+          # Get the first passwd, then loop until the last, yielding the current passwd.
+          pw = getpwent
+          until pw.nil?
+            yield pw 
+            pw = getpwent
+          end
+
+          # Reset passwd.
+          setpwent
+        end
+        getpwent
+      end
+
+      def setgrent
+        Mono::Unix::Native::Syscall.setgrent
+        nil
+      end
+
+      def setpwent
+        Mono::Unix::Native::Syscall.setpwent
+        nil
+      end
+
+      private
+
+      def from_clr_array(clr_array)
+        # to_a converts a System::Array to a Ruby Array,
+        # but doesn't convert the internals to Ruby types.
+        Array.new(clr_array.length){ |i| clr_array[i].to_s }
+      end
+
+      def to_group(result)
+        Struct::Group.new(result.gr_name.to_s, result.gr_passwd.to_s, Fixnum.induced_from(result.gr_gid), from_clr_array(result.gr_mem)) unless result.nil?
+      end
+
+      def to_passwd(result)
+        Struct::Passwd.new(result.pw_name.to_s, result.pw_passwd.to_s, Fixnum.induced_from(result.pw_uid), Fixnum.induced_from(result.pw_gid), result.pw_gecos.to_s, result.pw_dir.to_s, result.pw_shell.to_s) unless result.nil?
+      end
 
-    [:endpwent, :getgrent, :getgrgid, :getgrnam, :getpwent, 
-     :getpwnam, :getpwuid, :group, :passwd, :setgrent,
-     :setpwent].each do |method|
-      alias_method method, :endgrent
     end
   end
 end
+
diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/gem b/Merlin/Main/Languages/Ruby/Scripts/bin/gem
old mode 100644
new mode 100755
diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/irb b/Merlin/Main/Languages/Ruby/Scripts/bin/irb
old mode 100644
new mode 100755
diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/rdoc b/Merlin/Main/Languages/Ruby/Scripts/bin/rdoc
old mode 100644
new mode 100755
diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/ri b/Merlin/Main/Languages/Ruby/Scripts/bin/ri
old mode 100644
new mode 100755
diff --git a/Merlin/Main/Languages/Ruby/Scripts/dev.sh b/Merlin/Main/Languages/Ruby/Scripts/dev.sh
new file mode 100644
index 0000000..2e7e013
--- /dev/null
+++ b/Merlin/Main/Languages/Ruby/Scripts/dev.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+export CURRENT=`pwd`
+export RUBY_SCRIPTS=$CURRENT  
+DROP=${CURRENT:(-23)}
+export MERLIN_ROOT=${CURRENT%$DROP}
+
+# ruby needs to be on the path
+export RUBY18_BIN=
+export RUBY18_EXE=ruby
+export RUBY19_EXE=ruby1.9
+export RUBYOPT=
+<<<<<<< HEAD:Merlin/Main/Languages/Ruby/Scripts/dev.sh
+export GEM_PATH="$MERLIN_ROOT/../External.LCA_RESTRICTED/Languages/Ruby/ruby-1.8.6p368/lib/ruby/gems/1.8"
+=======
+export GEM_PATH="$MERLIN_ROOT/../External.LCA_RESTRICTED/Languages/Ruby/ruby-1.8.6p287/lib/ruby/gems/1.8"
+>>>>>>> linux:Merlin/Main/Languages/Ruby/Scripts/dev.sh
+
+chmod +x $MERLIN_ROOT/../External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin/{mspec,mspec-ci,mkspec,mspec-run,mspec-tag}    
+chmod +x $MERLIN_ROOT/Test/Scripts/ir
+
+export PATH="$MERLIN_ROOT/Languages/Ruby/Scripts:$MERLIN_ROOT/Languages/Ruby/Scripts/bin:$RUBY18_BIN:$MERLIN_ROOT/../External.LCA_RESTRICTED/Languages/IronRuby/mspec/mspec/bin:$PATH"
+          
+if [ ! -f ~/.mspecrc ]; then
+  cp $MERLIN_ROOT/Languages/Ruby/default.mspec ~/.mspecrc
+fi
+
+source $MERLIN_ROOT/Scripts/Bat/Alias.sh
+fp=`which $0`
+dir=`dirname $fp`
+cd $dir
+
+# Run user specific setup
+#if EXIST %MERLIN_ROOT%/../Users/%USERNAME%/Dev.bat call %MERLIN_ROOT%/../Users/%USERNAME%/Dev.bat
+
+clear 
diff --git a/Merlin/Main/Languages/Ruby/Tests/Scripts/irtest.rb b/Merlin/Main/Languages/Ruby/Tests/Scripts/irtest.rb
index 007d048..696f779 100644
--- a/Merlin/Main/Languages/Ruby/Tests/Scripts/irtest.rb
+++ b/Merlin/Main/Languages/Ruby/Tests/Scripts/irtest.rb
@@ -12,14 +12,23 @@ end
 
 flags = ["", "/partial", "/noadaptive", "/partial /noadaptive", "/sync0", "/sync1", "/debug", "/partial /debug"]
 
-ENV['ROWAN_BIN'] ||= "#{ENV['MERLIN_ROOT']}\\bin\\debug"
+# TODO: Check OS and set the debug folder name and cmd prefix appropriately.
+if RUBY_PLATFORM =~ /(mswin|mingw|bccwin|wince)/i then
+  debug_folder = 'debug'
+  cmd_prefix = ''
+else
+  debug_folder = 'mono_debug'
+  cmd_prefix = 'mono'
+end
+
+ENV['ROWAN_BIN'] ||= File.join("#{ENV['MERLIN_ROOT']}",'Bin',debug_folder)
 
 flags.each do |flag|  
-  cmd = "#{ENV['ROWAN_RUNTIME']} IronRuby.Tests.exe #{flag}"
+  cmd = cmd_prefix + "#{ENV['ROWAN_RUNTIME']} IronRuby.Tests.exe #{flag}"
   banner cmd
   Dir.chdir(ENV['ROWAN_BIN']) do
     exit 1 unless system cmd
   end
 end
 
-puts "OK"
+puts 'OK'
diff --git a/Merlin/Main/Languages/Ruby/default.mspec b/Merlin/Main/Languages/Ruby/default.mspec
index 6604352..231807a 100644
--- a/Merlin/Main/Languages/Ruby/default.mspec
+++ b/Merlin/Main/Languages/Ruby/default.mspec
@@ -12,4 +12,4 @@
 #
 #
 # ****************************************************************************
-load "#{ENV['MERLIN_ROOT']}\\..\\External.LCA_RESTRICTED\\Languages\\IronRuby\\mspec\\default.mspec"
+load File.join("#{ENV['MERLIN_ROOT']}",'..','External.LCA_RESTRICTED','Languages','IronRuby','mspec','default.mspec')
diff --git a/Merlin/Main/Test/Scripts/ir.sh b/Merlin/Main/Test/Scripts/ir.sh
new file mode 100755
index 0000000..8704db4
--- /dev/null
+++ b/Merlin/Main/Test/Scripts/ir.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+if [ '$ROWAN_BIN' = '' ]; then
+	export TEMP_IR_PATH=$MERLIN_ROOT/Bin/mono_debug
+else
+	export TEMP_IR_PATH=$ROWAN_BIN
+fi
+
+if [ '$IR_OPTIONS' = '' ]; then
+	export IR_OPTIONS=-X:Interpret
+fi
+
+export HOME=~/
+export RUBY_EXE=$TEMP_IR_PATH/ir.exe
+
+mono $TEMP_IR_PATH/ir.exe $IR_OPTIONS $*
+#
+# There should be no operations after this point so that the exitcode or ir.exe will be avilable as ERRORLEVEL
+#
