From be044a2d9973ed3943c92c24069c4b849fd6b8a4 Mon Sep 17 00:00:00 2001
From: "Tobias S. Josefowitz" <tobij@tobij.de>
Date: Wed, 9 Jan 2019 00:37:29 +0100
Subject: [PATCH] Process.run: Accept empty string in modifiers as stdin

Restores behaviour as of 7.8.

Fixes [LysLysKOM 23099651]. Thanks to Per Cederqvist for the report.
---
 CHANGES                  |  5 +++++
 lib/modules/Process.pmod | 23 ++++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/CHANGES b/CHANGES
index c6655a97a2..4b6b5d12ef 100644
--- a/CHANGES
+++ b/CHANGES
@@ -70,6 +70,11 @@ o Compiler
   - Fixed some corner cases where file names where missing from
     backtraces.
 
+o Process.run
+
+  - Don't error if stdin modifier is supplied as the empty string.
+    [LysLysKOM 23099651]
+
 o Protocols.HTTP.Session
 
   - Fix race-condition when multiple threads call give_me_connection()
diff --git a/lib/modules/Process.pmod b/lib/modules/Process.pmod
index a7368d7599..767d5a498c 100644
--- a/lib/modules/Process.pmod
+++ b/lib/modules/Process.pmod
@@ -611,15 +611,20 @@ mapping run(string|array(string) cmd, void|mapping modifiers)
 				});
 
   if (mystdin) {
-    Shuffler.Shuffler sfr = Shuffler.Shuffler();
-    sfr->set_backend (backend);
-    Shuffler.Shuffle sf = sfr->shuffle( mystdin );
-    sf->add_source(stdin_str);
-    sf->set_done_callback (lambda () {
-			     catch { mystdin->close(); };
-			     mystdin = 0;
-			   });
-    sf->start();
+    if (stdin_str != "") {
+      Shuffler.Shuffler sfr = Shuffler.Shuffler();
+      sfr->set_backend (backend);
+      Shuffler.Shuffle sf = sfr->shuffle( mystdin );
+      sf->add_source(stdin_str);
+      sf->set_done_callback (lambda () {
+                               catch { mystdin->close(); };
+                               mystdin = 0;
+                             });
+      sf->start();
+    } else {
+      catch { mystdin->close(); };
+      mystdin = 0;
+    }
   }
 
   while( mystdout || mystderr || mystdin )
-- 
GitLab