aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-08 09:28:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-08 09:28:15 +0200
commitc8802a33677dd84b5736c333c6821d6eba992b97 (patch)
tree0548cf802cab45d028c80b7fe69eab86c011ae18
parentcce149a53923bde3a78159e164794058bedc2909 (diff)
Add process_path::clear_recall()
-rw-r--r--libbutl/process.ixx10
-rw-r--r--libbutl/process.mxx10
2 files changed, 19 insertions, 1 deletions
diff --git a/libbutl/process.ixx b/libbutl/process.ixx
index c7459c8..17c5daa 100644
--- a/libbutl/process.ixx
+++ b/libbutl/process.ixx
@@ -79,6 +79,16 @@ namespace butl
return effect.empty () ? recall_string () : effect.string ().c_str ();
}
+ inline void process_path::
+ clear_recall ()
+ {
+ if (!effect.empty ())
+ {
+ recall = std::move (effect);
+ effect.clear ();
+ }
+ }
+
// process_exit
//
#ifdef _WIN32
diff --git a/libbutl/process.mxx b/libbutl/process.mxx
index 7a331da..a0c021c 100644
--- a/libbutl/process.mxx
+++ b/libbutl/process.mxx
@@ -124,6 +124,11 @@ LIBBUTL_MODEXPORT namespace butl
return initial == nullptr && recall.empty () && effect.empty ();
}
+ // Clear recall making it the same as effective.
+ //
+ void
+ clear_recall ();
+
// Moveable-only type.
//
process_path (process_path&&);
@@ -406,7 +411,10 @@ LIBBUTL_MODEXPORT namespace butl
// (like calling process' directory and, gasp, CWD on Windows).
//
// If the paths argument is not NULL, search in this list of paths rather
- // than in the PATH environment variable.
+ // than in the PATH environment variable. Note that in this case you may
+ // want to clear the recall path (process_path::clear_recall()) since the
+ // path won't be "recallable" (unless you've passed a cache of the PATH
+ // environment variable or some such).
//
static process_path
path_search (const char*& args0,