summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2014-05-27 10:21:34 +0100
committerColin Fletcher <colin.m.fletcher@googlemail.com>2014-06-12 23:20:05 +0100
commit724a69a8d554151f3d1ec4bed03c6c4ab6f11eed (patch)
tree633b9c21df0face6cfe2e0a3fff055b837c003b6
parenta24525040922c466fe3b3b89b88ba6ed02cbb799 (diff)
Search $PATH for command when creating SystemExec from command line
When creating a SystemExec from a command-line, search $PATH for the command to execute, so that post-export hooks don't need to specify a full path.
-rw-r--r--libs/pbd/system_exec.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc
index 7e94880f85..a5dd20afac 100644
--- a/libs/pbd/system_exec.cc
+++ b/libs/pbd/system_exec.cc
@@ -43,9 +43,12 @@
#include <sys/resource.h>
#endif
+#include <glibmm/miscutils.h>
#define USE_VFORK
+#include "pbd/file_utils.h"
+#include "pbd/search_path.h"
#include "pbd/system_exec.h"
using namespace std;
@@ -192,8 +195,14 @@ SystemExec::SystemExec (std::string command, const std::map<char, std::string> s
{
init ();
make_argp_escaped(command, subs);
- cmd = argp[0];
- // cmd = strdup(argp[0]);
+ if (!find_file_in_search_path (Searchpath (Glib::getenv ("PATH")), argp[0], cmd)) {
+ // not found in path - use as-is
+ cmd = argp[0];
+ }
+
+ // Glib::find_program_in_path () is only available in Glib >= 2.28
+ // cmd = Glib::find_program_in_path (argp[0]);
+
make_envp();
}