more direct File.executable operation: avoid external process (on Unix);
authorwenzelm
Wed, 05 Dec 2018 22:46:44 +0100
changeset 69405 22428643351f
parent 69404 de88761edbe2
child 69406 5e5f1109c783
more direct File.executable operation: avoid external process (on Unix);
src/Pure/Admin/build_cygwin.scala
src/Pure/Admin/build_release.scala
src/Pure/General/file.scala
--- a/src/Pure/Admin/build_cygwin.scala	Wed Dec 05 21:36:18 2018 +0100
+++ b/src/Pure/Admin/build_cygwin.scala	Wed Dec 05 22:46:44 2018 +0100
@@ -35,9 +35,8 @@
 
         File.write(cygwin_isabelle + Path.explode("cygwin_mirror"), mirror)
 
-        Isabelle_System.bash(
-          "chmod +x " + File.bash_path(cygwin_exe) + " && " +
-          File.bash_path(cygwin_exe) + " -h </dev/null >/dev/null").check
+        File.executable(cygwin_exe)
+        Isabelle_System.bash(File.bash_path(cygwin_exe) + " -h </dev/null >/dev/null").check
 
         val res =
           progress.bash(
--- a/src/Pure/Admin/build_release.scala	Wed Dec 05 21:36:18 2018 +0100
+++ b/src/Pure/Admin/build_release.scala	Wed Dec 05 22:46:44 2018 +0100
@@ -466,7 +466,7 @@
                 .replaceAllLiterally("{CLASSPATH}",
                   classpath.map("$ISABELLE_HOME/" + _).mkString(":"))
                 .replaceAllLiterally("/jdk/", "/" + jdk_component + "/"))
-            Isabelle_System.bash("chmod +x " + File.bash_path(isabelle_run)).check
+            File.executable(isabelle_run)
 
             val linux_app = isabelle_target + Path.explode("contrib/linux_app")
             File.move(linux_app + Path.explode("Isabelle"),
@@ -530,8 +530,7 @@
             File.write(isabelle_target + cygwin_bat,
               File.read(cygwin_template + cygwin_bat)
                 .replaceAllLiterally("{MIRROR}", cygwin_mirror))
-
-            Isabelle_System.bash("chmod +x " + File.bash_path(isabelle_target + cygwin_bat)).check
+            File.executable(isabelle_target + cygwin_bat)
 
             for (name <- List("isabelle/postinstall", "isabelle/rebaseall")) {
               val path = Path.explode(name)
@@ -654,8 +653,7 @@
 
             Bytes.write(release.dist_dir + isabelle_exe,
               Bytes.read(sfx_exe) + Bytes(sfx_txt) + Bytes.read(exe_archive))
-
-            Isabelle_System.bash("chmod +x " + (release.dist_dir + isabelle_exe)).check
+            File.executable(release.dist_dir + isabelle_exe)
           }
         })
         progress.echo("DONE")
--- a/src/Pure/General/file.scala	Wed Dec 05 21:36:18 2018 +0100
+++ b/src/Pure/General/file.scala	Wed Dec 05 22:46:44 2018 +0100
@@ -331,4 +331,13 @@
         Cygwin.link(standard_path(src), target)
     }
   }
+
+
+  /* permissions */
+
+  def executable(path: Path)
+  {
+    if (Platform.is_windows) Isabelle_System.bash("chmod a+x " + bash_path(path)).check
+    else path.file.setExecutable(true, false)
+  }
 }