diff --git a/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command_line/dash_upper_s_spec.rb b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command_line/dash_upper_s_spec.rb
new file mode 100644
index 0000000..7f17114
--- /dev/null
+++ b/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/command_line/dash_upper_s_spec.rb
@@ -0,0 +1,24 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe "The -S command line option" do
+  it 'finds the file on the path' do
+    this_dir = File.expand_path(File.dirname(__FILE__))
+    fixture_dir = File.expand_path(this_dir + '/../fixtures')
+
+    ENV['PATH'] = "#{fixture_dir};#{ENV['PATH']}"
+    dash_s = ruby_exe(nil, :options => '-S file.rb')
+
+    ENV['PATH'] = ENV['PATH'].split(';')[1..-1].join(';')
+    expected = ruby_exe("#{fixture_dir}/file.rb")
+    failed_dash_s = ruby_exe(nil, :args => "-S #{this_dir}/file.rb 2>&1")
+
+    dash_s.should == expected
+    dash_s.should_not == failed_dash_s
+  end
+
+  it 'does not find the file on the path' do
+    dash_s = ruby_exe(nil, :args => '-S does/not/exist.rb 2>&1')
+    normal = ruby_exe(nil, :args => 'does/not/exist.rb 2>&1')
+    dash_s.should == normal
+  end
+end
diff --git a/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs b/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs
index 25284c2..13be5f9 100644
--- a/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs
+++ b/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs
@@ -89,6 +89,8 @@ namespace IronRuby.Hosting {
         protected override void ParseArgument(string arg) {
             ContractUtils.RequiresNotNull(arg, "arg");
 
+            string mainFileFromPath = null;
+
             if (arg.StartsWith("-e", StringComparison.Ordinal)) {
                 string command;
                 if (arg == "-e") {
@@ -107,6 +109,10 @@ namespace IronRuby.Hosting {
                 return;
             }
 
+            if (arg.StartsWith("-S", StringComparison.Ordinal)) {
+                mainFileFromPath = arg == "-S" ? PopNextArg() : arg.Substring(2);
+            }
+
             if (arg.StartsWith("-I", StringComparison.Ordinal)) {
                 string includePaths;
                 if (arg == "-I") {
@@ -164,7 +170,6 @@ namespace IronRuby.Hosting {
                 case "-n":
                 case "-p":
                 case "-s":
-                case "-S":
                     throw new InvalidOptionException(String.Format("Option `{0}' not supported", optionName));
 
                 case "-d":
@@ -262,6 +267,20 @@ namespace IronRuby.Hosting {
                     base.ParseArgument(arg);
 
                     if (ConsoleOptions.FileName != null) {
+                        if (mainFileFromPath != null) {
+                            ConsoleOptions.FileName = null;
+                            string path = Platform.GetEnvironmentVariable("PATH");
+                            foreach (string p in path.Split(';')) {
+                                string fullPath = RubyUtils.CombinePaths(p, mainFileFromPath);
+                                if (Platform.FileExists(fullPath)) {
+                                    ConsoleOptions.FileName = fullPath;
+                                    break;
+                                }
+                            }
+                            if (ConsoleOptions.FileName == null) {
+                                ConsoleOptions.FileName = mainFileFromPath;
+                            }
+                        }
                         LanguageSetup.Options["MainFile"] = RubyUtils.CanonicalizePath(ConsoleOptions.FileName);
                         LanguageSetup.Options["Arguments"] = PopRemainingArgs();
                         LanguageSetup.Options["ArgumentEncoding"] = 
@@ -331,7 +350,7 @@ namespace IronRuby.Hosting {
              // { "-p",                          "assume loop like -n but print line also like sed" },
                 { "-rlibrary",                   "require the library, before executing your script" },
              // { "-s",                          "enable some switch parsing for switches after script name" },
-             // { "-S",                          "look for the script using PATH environment variable" },
+                { "-S",                          "look for the script using PATH environment variable" },
              // { "-T[level]",                   "turn on tainting checks" },
                 { "-v",                          "print version number, then turn on verbose mode" },
                 { "-w",                          "turn warnings on for your script" },
