[gnome-builder] build-command: enable shell expansion from build commands



commit 3ffcf2505bbf3ddd582ad871d5a2011e13b64e33
Author: Christian Hergert <chergert redhat com>
Date:   Fri Sep 16 14:05:46 2016 -0700

    build-command: enable shell expansion from build commands
    
    When executing an IdeBuildCommand, we should allow expansion of shell
    variables so things like $HOME or $PATH will work.
    
    This uses the venerable sh -c "command" to execute the command within
    a shell (and therefore gain access to it's environment).

 libide/buildsystem/ide-build-command.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/libide/buildsystem/ide-build-command.c b/libide/buildsystem/ide-build-command.c
index 300133c..72990b5 100644
--- a/libide/buildsystem/ide-build-command.c
+++ b/libide/buildsystem/ide-build-command.c
@@ -77,8 +77,6 @@ create_launcher (IdeBuildCommand  *self,
                  GError          **error)
 {
   g_autoptr(IdeSubprocessLauncher) launcher = NULL;
-  g_auto(GStrv) argv = NULL;
-  gint argc;
 
   g_assert (IDE_IS_BUILD_COMMAND (self));
   g_assert (IDE_IS_RUNTIME (runtime));
@@ -97,17 +95,15 @@ create_launcher (IdeBuildCommand  *self,
   if (NULL == (launcher = ide_runtime_create_launcher (runtime, error)))
     return NULL;
 
-  ide_subprocess_launcher_set_flags (launcher,
-                                     (G_SUBPROCESS_FLAGS_STDERR_PIPE | G_SUBPROCESS_FLAGS_STDOUT_PIPE));
+  ide_subprocess_launcher_set_flags (launcher, (G_SUBPROCESS_FLAGS_STDERR_PIPE | 
G_SUBPROCESS_FLAGS_STDOUT_PIPE));
   ide_subprocess_launcher_overlay_environment (launcher, environment);
 
   /* TODO: ide_subprocess_launcher_set_cwd (launcher, builddir); */
   /* TODO: set $BUILDDIR and $SRCDIR for scripts? */
 
-  if (!g_shell_parse_argv (command_text, &argc, &argv, error))
-    return NULL;
-
-  ide_subprocess_launcher_push_args (launcher, (const gchar * const *)argv);
+  ide_subprocess_launcher_push_argv (launcher, "sh");
+  ide_subprocess_launcher_push_argv (launcher, "-c");
+  ide_subprocess_launcher_push_argv (launcher, command_text);
 
   return g_steal_pointer (&launcher);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]