From 4bd52dd0b895e08ccc0316bfef1fbb8e478a9654 Mon Sep 17 00:00:00 2001
From: Chris Hanson <org/chris-hanson/cph>
Date: Thu, 30 Sep 2010 02:20:15 -0700
Subject: [PATCH] Apply patch from Eric Christopherson to allow calling
 mit-scheme.app/Contents/Resources/mit-scheme from command line.

---
 src/microcode/macosx-starter.c |  2 +-
 src/microcode/option.c         | 18 +++++++++++++++++-
 src/microcode/option.h         |  3 +++
 src/microcode/uxtop.c          |  2 ++
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/microcode/macosx-starter.c b/src/microcode/macosx-starter.c
index 3df6ae8b5..e96c1617f 100644
--- a/src/microcode/macosx-starter.c
+++ b/src/microcode/macosx-starter.c
@@ -57,7 +57,7 @@ main (int argc, const char ** argv)
   pid = (vfork ());
   if (pid == 0)
     {
-      execl (bp, bp, "--edit", ((char *) 0));
+      execl (bp, bp, "--macosx-application", "--edit", ((char *) 0));
       _exit (1);
     }
   return ((pid > 0) ? 0 : 3);
diff --git a/src/microcode/option.c b/src/microcode/option.c
index ad9045fc2..5b79b8e89 100644
--- a/src/microcode/option.c
+++ b/src/microcode/option.c
@@ -104,6 +104,9 @@ bool option_disable_core_dump;
 bool option_batch_mode;
 bool option_show_version;
 bool option_show_help;
+#ifdef __APPLE__
+  bool option_macosx_application;
+#endif
 
 /* String options */
 const char ** option_library_path = 0;
@@ -186,7 +189,17 @@ for the band.\n\
 --nocore\n\
   Specifies that Scheme should not generate a core dump under any\n\
   circumstances.\n\
-\n\
+"
+#ifdef __APPLE__
+"\n\
+--macosx-application\n\
+  Specifies that Scheme is running as a Mac OS X application.\n\
+  This option is automatically supplied when the application is\n\
+  launched from an icon, and should not be given under other\n\
+  circumstances.\n\
+"
+#endif /* __APPLE__ */
+"\n\
 Please report bugs to %s.\n\
 \n\
 Additional options may be supported by the band (and described below).\n\
@@ -479,6 +492,9 @@ parse_standard_options (int argc, const char ** argv)
   option_argument ("help", false, (&option_show_help));
   option_argument ("interactive", false, (&option_force_interactive));
   option_argument ("library", true, (&option_raw_library));
+#ifdef __APPLE__
+  option_argument ("macosx-application", false, (&option_macosx_application));
+#endif
   option_argument ("nocore", false, (&option_disable_core_dump));
   option_argument ("option-summary", false, (&option_summary));
   option_argument ("quiet", false, (&option_batch_mode));
diff --git a/src/microcode/option.h b/src/microcode/option.h
index 9fa346294..12993868f 100644
--- a/src/microcode/option.h
+++ b/src/microcode/option.h
@@ -40,6 +40,9 @@ extern bool option_disable_core_dump;
 extern bool option_batch_mode;
 extern bool option_show_help;
 extern bool option_show_version;
+#ifdef __APPLE__
+  extern bool option_macosx_application;
+#endif
 
 /* String options */
 extern const char ** option_library_path;
diff --git a/src/microcode/uxtop.c b/src/microcode/uxtop.c
index 37ac880e4..86eb805c4 100644
--- a/src/microcode/uxtop.c
+++ b/src/microcode/uxtop.c
@@ -232,6 +232,8 @@ macosx_main_bundle_dir (void)
 bool
 macosx_in_app_p (void)
 {
+  if (!option_macosx_application)
+    return (false);
   CFURLRef url = (macosx_default_band_url ());
   if (url == 0)
     return (false);
-- 
2.25.1