[gnome-builder] subprocess: add helper to append to $PATH
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] subprocess: add helper to append to $PATH
- Date: Tue, 16 Jan 2018 08:50:39 +0000 (UTC)
commit bdc1895cc80b3b9066fe4fc46577ff2dd4fee51e
Author: Christian Hergert <chergert redhat com>
Date: Tue Jan 16 00:42:35 2018 -0800
subprocess: add helper to append to $PATH
This is useful in situations where we need to getenv, append,
setenv.
src/libide/subprocess/ide-subprocess-launcher.c | 24 ++++++++++++++++++++++++
src/libide/subprocess/ide-subprocess-launcher.h | 3 +++
2 files changed, 27 insertions(+)
---
diff --git a/src/libide/subprocess/ide-subprocess-launcher.c b/src/libide/subprocess/ide-subprocess-launcher.c
index ee374bb0c..957305452 100644
--- a/src/libide/subprocess/ide-subprocess-launcher.c
+++ b/src/libide/subprocess/ide-subprocess-launcher.c
@@ -996,3 +996,27 @@ ide_subprocess_launcher_set_stdout_file_path (IdeSubprocessLauncher *self,
priv->stdout_file_path = g_strdup (stdout_file_path);
}
}
+
+void
+ide_subprocess_launcher_append_path (IdeSubprocessLauncher *self,
+ const gchar *path)
+{
+ const gchar *old_path;
+
+ g_return_if_fail (IDE_IS_SUBPROCESS_LAUNCHER (self));
+
+ if (path == NULL)
+ return;
+
+ old_path = ide_subprocess_launcher_getenv (self, "PATH");
+
+ if (old_path != NULL)
+ {
+ g_autofree gchar *new_path = g_strdup_printf ("%s:%s", old_path, path);
+ ide_subprocess_launcher_setenv (self, "PATH", new_path, TRUE);
+ }
+ else
+ {
+ ide_subprocess_launcher_setenv (self, "PATH", path, TRUE);
+ }
+}
diff --git a/src/libide/subprocess/ide-subprocess-launcher.h b/src/libide/subprocess/ide-subprocess-launcher.h
index 360774f27..ea580c2f2 100644
--- a/src/libide/subprocess/ide-subprocess-launcher.h
+++ b/src/libide/subprocess/ide-subprocess-launcher.h
@@ -66,6 +66,9 @@ gboolean ide_subprocess_launcher_get_run_on_host (IdeSubproces
IDE_AVAILABLE_IN_ALL
void ide_subprocess_launcher_set_run_on_host (IdeSubprocessLauncher *self,
gboolean run_on_host);
+IDE_AVAILABLE_IN_3_28
+void ide_subprocess_launcher_append_path (IdeSubprocessLauncher *self,
+ const gchar *append_path);
IDE_AVAILABLE_IN_ALL
gboolean ide_subprocess_launcher_get_clear_env (IdeSubprocessLauncher *self);
IDE_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]