From 4a5f02698e5f2cf78cc84201f15a63000789d86a Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Tue, 4 Aug 2009 14:55:41 +0300 Subject: [PATCH] Ticket #1425 (External editor won't open if there are spaces in EDITOR variable) Fix issue: in function src/utillinux.c:my_system() added code for splitting command line by spaces, use just first token as argument to function execlp() Signed-off-by: Slava Zanko --- src/utilunix.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/utilunix.c b/src/utilunix.c index 0dade587a..389442d23 100644 --- a/src/utilunix.c +++ b/src/utilunix.c @@ -163,7 +163,25 @@ int my_system (int flags, const char *shell, const char *command) if (flags & EXECUTE_AS_SHELL) execl (shell, shell, "-c", command, (char *) NULL); else - execlp (shell, shell, command, (char *) NULL); + { + gchar **shell_tokens, *only_cmd; + shell_tokens = g_strsplit(shell," ", 2); + + if (shell_tokens == NULL) + only_cmd = shell; + else + only_cmd = (*shell_tokens) ? *shell_tokens: shell; + + execlp (only_cmd, shell, command, (char *) NULL); + + /* + execlp will replace current process, + therefore no sence in call of g_strfreev(). + But this keeped for estetic reason :) + */ + g_strfreev(shell_tokens); + + } _exit (127); /* Exec error */ } else {