more robust: avoid accidental use of stdin;
authorwenzelm
Mon, 16 Dec 2019 15:18:03 +0100
changeset 71284 49bc17bf4384
parent 71283 cfcc1a2233ca
child 71285 8cd05f7b3b4a
more robust: avoid accidental use of stdin;
src/Pure/Tools/phabricator.scala
--- a/src/Pure/Tools/phabricator.scala	Mon Dec 16 13:58:46 2019 +0100
+++ b/src/Pure/Tools/phabricator.scala	Mon Dec 16 15:18:03 2019 +0100
@@ -76,17 +76,18 @@
     exit: String = ""): String =
   {
 """#!/bin/bash
-
-{""" + (if (init.nonEmpty) "\n" + Library.prefix_lines("  ", init) else "") + """
+""" + (if (init.nonEmpty) "\n" + init else "") + """
+{
   while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; }
   do
     NAME="$(echo "$REPLY" | cut -d: -f1)"
     ROOT="$(echo "$REPLY" | cut -d: -f2)"
-""" + Library.prefix_lines("    ", body) + """
-  done""" +
-    (if (exit.nonEmpty) "\n" + Library.prefix_lines("  ", exit) else "") + """
-} < """ + File.bash_path(global_config) + """
-"""
+    {
+""" + Library.prefix_lines("      ", body) + """
+    } < /dev/null
+  done
+} < """ + File.bash_path(global_config) + "\n" +
+    (if (exit.nonEmpty) "\n" + exit + "\n" else "")
   }
 
   sealed case class Config(name: String, root: Path)