add option to forward environment to pipestream
[libi2ncommon] / src / pipestream.hxx
index f53f474..8668df3 100644 (file)
@@ -71,10 +71,10 @@ typedef struct ExecResult ExecResult;
 std::string capture_exec(const std::string& command, ExecResult &rescode);
 std::string capture_exec(const char *const *command, ExecResult &rescode,
                          const bool out=true, const bool err=false,
-                         const bool path=false);
+                         const bool path=false, const bool env=false);
 std::string capture_exec(const std::vector<std::string>& command, ExecResult &rescode,
                          const bool out=true, const bool err=false,
-                         const bool path=false);
+                         const bool path=false, const bool env=false);
 
 inline std::string capture_exec (const std::string &command)
 {
@@ -117,11 +117,11 @@ protected:
 
 public:
     inpipebuf(const std::string& command,
-              const bool out, const bool err, const bool path);
+              const bool out, const bool err, const bool path, const bool env);
     inpipebuf(const char *const *command,
-              const bool out, const bool err, const bool path);
+              const bool out, const bool err, const bool path, const bool env);
     inpipebuf(const std::vector<std::string> &command,
-              const bool out, const bool err, const bool path);
+              const bool out, const bool err, const bool path, const bool env);
 
     ~inpipebuf();
 
@@ -134,7 +134,7 @@ private:
     std::pair <pid_t, FILE *>
     init_without_shell (const char *const *argv,
                         const bool out, const bool err,
-                        const bool path) const;
+                        const bool path, const bool env) const;
 };
 
 /** @brief stream around inpipebuf -- see comment there */
@@ -146,20 +146,20 @@ protected:
 public:
     inpipestream(const std::string& command,
                  const bool out=true, const bool err=false,
-                 const bool path=false)
-            : std::istream(&buf), buf(command, out, err, path)
+                 const bool path=false, const bool env=false)
+            : std::istream(&buf), buf(command, out, err, path, env)
     {}
 
     inpipestream(const char *const command[],
                  const bool out=true, const bool err=false,
-                 const bool path=false)
-            : std::istream(&buf), buf(command, out, err, path)
+                 const bool path=false, const bool env=false)
+            : std::istream(&buf), buf(command, out, err, path, env)
     {}
 
     inpipestream(const std::vector<std::string> &command,
                  const bool out=true, const bool err=false,
-                 const bool path=false)
-            : std::istream(&buf), buf(command, out, err, path)
+                 const bool path=false, const bool env=false)
+            : std::istream(&buf), buf(command, out, err, path, env)
     {}
 
     void store_exit_status(bool *_status_set, int *_exit_status)