aboutsummaryrefslogtreecommitdiff
path: root/libbutl/process-io.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-09-28 19:24:31 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-09-28 20:29:59 +0300
commitdf1ef68cd8e8582724ce1192bfc202e0b9aeaf0c (patch)
treeb731ca4c68e60c00c7e7d499dbf4868ee7b71f44 /libbutl/process-io.hxx
parent7a4fc37f264cdb67f2f83fa92703c869215bbc86 (diff)
Get rid of C++ modules related code and rename *.mxx files to *.hxx
Diffstat (limited to 'libbutl/process-io.hxx')
-rw-r--r--libbutl/process-io.hxx50
1 files changed, 50 insertions, 0 deletions
diff --git a/libbutl/process-io.hxx b/libbutl/process-io.hxx
new file mode 100644
index 0000000..29d6d8b
--- /dev/null
+++ b/libbutl/process-io.hxx
@@ -0,0 +1,50 @@
+// file : libbutl/process-io.hxx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+#pragma once
+
+#include <ostream>
+
+#include <libbutl/process.hxx>
+
+#include <libbutl/export.hxx>
+
+namespace butl
+{
+ inline std::ostream&
+ operator<< (std::ostream& o, const process_path& p)
+ {
+ return o << p.recall_string ();
+ }
+
+ inline std::ostream&
+ operator<< (std::ostream& o, const process_args& a)
+ {
+ process::print (o, a.argv, a.argc);
+ return o;
+ }
+
+ // Print the environment variables and the current working directory (if
+ // specified) in a POSIX shell command line notation. The process path
+ // itself is not printed. For example:
+ //
+ // LC_ALL=C
+ //
+ // If an environment variable is in the `name` rather than in the
+ // `name=value` form, then it is considered unset. Since there is no POSIX
+ // way to unset a variable on the command line, this information is printed
+ // as `name=` (ambiguous with assigning an empty value but the two cases are
+ // normally handled in the same way). For example:
+ //
+ // PATH= LC_ALL=C
+ //
+ // Note that since there is no POSIX way to change the current working
+ // directory of a command to be executed, this information is printed in a
+ // pseudo-notation by assigning to PWD (which, according POSIX, would result
+ // in the undefined behavior of the cwd utility). For example:
+ //
+ // PWD=/tmp LC_ALL=C
+ //
+ LIBBUTL_SYMEXPORT std::ostream&
+ operator<< (std::ostream&, const process_env&);
+}