eliminated hardwired Cygwin setup;
authorwenzelm
Mon Jun 08 00:26:57 2009 +0200 (2009-06-08)
changeset 31500eced346b2231
parent 31499 4345173ee386
child 31501 2a60c9b951e0
child 31502 e2de58666d21
child 31506 ff0ab207849a
eliminated hardwired Cygwin setup;
src/Pure/System/isabelle_system.scala
     1.1 --- a/src/Pure/System/isabelle_system.scala	Mon Jun 08 00:20:43 2009 +0200
     1.2 +++ b/src/Pure/System/isabelle_system.scala	Mon Jun 08 00:26:57 2009 +0200
     1.3 @@ -58,6 +58,18 @@
     1.4  
     1.5    /* Isabelle settings environment */
     1.6  
     1.7 +  private val (cygdrive_pattern, cygwin_root, shell_prefix) =
     1.8 +  {
     1.9 +    if (IsabelleSystem.is_cygwin) {
    1.10 +      val cygdrive = Cygwin.cygdrive getOrElse "/cygdrive"
    1.11 +      val pattern = Pattern.compile(cygdrive + "/([a-zA-Z])($|/.*)")
    1.12 +      val root = Cygwin.root getOrElse "C:\\cygwin"
    1.13 +      val bash = List(root + "\\bin\\bash", "-l")
    1.14 +      (Some(pattern), Some(root), bash)
    1.15 +    }
    1.16 +    else (None, None, Nil)
    1.17 +  }
    1.18 +
    1.19    private val environment: Map[String, String] =
    1.20    {
    1.21      import scala.collection.jcl.Conversions._
    1.22 @@ -75,9 +87,7 @@
    1.23  
    1.24      val dump = File.createTempFile("isabelle", null)
    1.25      try {
    1.26 -      val cmdline =
    1.27 -        (if (IsabelleSystem.is_cygwin) List("C:\\cygwin\\bin\\bash", "-l") else Nil) ++
    1.28 -        List(isabelle, "getenv", "-d", dump.toString)
    1.29 +      val cmdline = shell_prefix ::: List(isabelle, "getenv", "-d", dump.toString)
    1.30        val proc = IsabelleSystem.raw_execute(env0, true, cmdline: _*)
    1.31        val (output, rc) = IsabelleSystem.process_output(proc)
    1.32        if (rc != 0) error(output)
    1.33 @@ -107,29 +117,36 @@
    1.34  
    1.35    /* file path specifications */
    1.36  
    1.37 -  private val cygdrive_pattern = Pattern.compile("/cygdrive/([a-zA-Z])($|/.*)")
    1.38 -
    1.39    def platform_path(source_path: String): String =
    1.40    {
    1.41      val result_path = new StringBuilder
    1.42  
    1.43 -    def init(path: String): String =
    1.44 +    def init_plain(path: String): String =
    1.45      {
    1.46 -      val cygdrive = cygdrive_pattern.matcher(path)
    1.47 -      if (cygdrive.matches) {
    1.48 -        result_path.length = 0
    1.49 -        result_path.append(cygdrive.group(1))
    1.50 -        result_path.append(":")
    1.51 -        result_path.append(File.separator)
    1.52 -        cygdrive.group(2)
    1.53 -      }
    1.54 -      else if (path.startsWith("/")) {
    1.55 +      if (path.startsWith("/")) {
    1.56          result_path.length = 0
    1.57          result_path.append(getenv_strict("ISABELLE_ROOT_JVM"))
    1.58          path.substring(1)
    1.59        }
    1.60        else path
    1.61      }
    1.62 +    def init(path: String): String =
    1.63 +    {
    1.64 +      cygdrive_pattern match {
    1.65 +        case Some(pattern) =>
    1.66 +          val cygdrive = pattern.matcher(path)
    1.67 +          if (cygdrive.matches) {
    1.68 +            result_path.length = 0
    1.69 +            result_path.append(cygdrive.group(1))
    1.70 +            result_path.append(":")
    1.71 +            result_path.append(File.separator)
    1.72 +            cygdrive.group(2)
    1.73 +          }
    1.74 +          else init_plain(path)
    1.75 +        case None => init_plain(path)
    1.76 +      }
    1.77 +    }
    1.78 +
    1.79      def append(path: String)
    1.80      {
    1.81        for (p <- init(path).split("/")) {