<p>When you do a "Find in Files" search, it will show the search command in the first line of the results.</p>
<p>However, this is quite badly broken. It does not include the directory specifier part of the command, and it doesn't provide escaping (e.g. quoting) of search terms.</p>
<p>I have fixed it in the patch below. I don't know if people are going to like my patch, because I re-used <code>spawn_append_argument</code> from the Windows code to build up the arguments, which is probably messy and not 100% perfect. However the Unix code is trusting the command line build up to something deeper in GLib (<code>g_spawn_async_with_pipes</code>) so I can't get at the final command line built up made with that code.</p>
<p>IMO What I have is an improvement if not perfect, but there may be a better solution so I'll leave that to wiser minds.</p>
<div class="highlight highlight-source-diff"><pre><span class="pl-c1">diff --git a/src/search.c b/src/search.c</span>
index 934d06f5..0b85f0d8 100644
<span class="pl-md">--- a/src/search.c</span>
<span class="pl-mi1">+++ b/src/search.c</span>
<span class="pl-mdr">@@ -1694,11 +1694,17 @@</span> search_find_in_files(const gchar *utf8_search_text, const gchar *utf8_dir, const
                NULL, &error))
        {
                gchar *utf8_str;
<span class="pl-mi1"><span class="pl-mi1">+</span>                GString *argv_escaped_together = g_string_new("");</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                gchar **argv_tmp = argv;</span>
<span class="pl-mi1"><span class="pl-mi1">+</span></span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                while (argv_tmp && *argv_tmp)</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                        spawn_append_argument(argv_escaped_together, *argv_tmp++);</span>
 
                ui_progress_bar_start(_("Searching..."));
                msgwin_set_messages_dir(dir);
<span class="pl-md"><span class="pl-md">-</span>          utf8_str = g_strdup_printf(_("%s %s -- %s (in directory: %s)"),</span>
<span class="pl-md"><span class="pl-md">-</span>                  tool_prefs.grep_cmd, opts, utf8_search_text, utf8_dir);</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                utf8_str = g_strdup_printf(_("%s %s (in directory: %s)"),</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                        command_line, argv_escaped_together->str, utf8_dir);</span>
                msgwin_msg_add_string(COLOR_BLUE, -1, NULL, utf8_str);
                g_free(utf8_str);
<span class="pl-mi1"><span class="pl-mi1">+</span>                g_string_free(argv_escaped_together, TRUE);</span>
                ret = TRUE;
<span class="pl-c1">diff --git a/src/spawn.c b/src/spawn.c</span>
index 1d4e4292..7e390977 100644
<span class="pl-md">--- a/src/spawn.c</span>
<span class="pl-mi1">+++ b/src/spawn.c</span>
<span class="pl-mdr">@@ -52,8 +52,9 @@</span>
 
 #include "spawn.h"
 
<span class="pl-mi1"><span class="pl-mi1">+</span>#include <ctype.h>    /* isspace() */</span>
<span class="pl-mi1"><span class="pl-mi1">+</span></span>
 #ifdef G_OS_WIN32
<span class="pl-md"><span class="pl-md">-</span># include <ctype.h>    /* isspace() */</span>
 # include <fcntl.h>    /* _O_RDONLY, _O_WRONLY */
 # include <io.h>       /* _open_osfhandle, _close */
 # include <windows.h>
<span class="pl-mdr">@@ -436,8 +437,9 @@</span> leave:
        return failure;
 }
 
<span class="pl-mi1"><span class="pl-mi1">+</span>#endif /* G_OS_WIN32 */</span>
 
<span class="pl-md"><span class="pl-md">-</span>static void spawn_append_argument(GString *command, const char *text)</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>void spawn_append_argument(GString *command, const char *text)</span>
 {
        const char *s;
 
<span class="pl-mdr">@@ -487,7 +489,6 @@</span> static void spawn_append_argument(GString *command, const char *text)
                g_string_append_c(command, '"');
        }
 }
<span class="pl-md"><span class="pl-md">-</span>#endif /* G_OS_WIN32 */</span>
 
 
 /*
<span class="pl-c1">diff --git a/src/spawn.h b/src/spawn.h</span>
index ccfca269..04337054 100644
<span class="pl-md">--- a/src/spawn.h</span>
<span class="pl-mi1">+++ b/src/spawn.h</span>
<span class="pl-mdr">@@ -45,6 +45,8 @@</span> gboolean spawn_kill_process(GPid pid, GError **error);
 gboolean spawn_async(const gchar *working_directory, const gchar *command_line, gchar **argv,
        gchar **envp, GPid *child_pid, GError **error);
 
<span class="pl-mi1"><span class="pl-mi1">+</span>void spawn_append_argument(GString *command, const char *text);</span>
<span class="pl-mi1"><span class="pl-mi1">+</span></span>
 /** Flags passed to @c spawn_with_callbacks(), which see. */
 typedef enum
 {</pre></div>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/2424?email_source=notifications&email_token=AAIOWJZGM7UJMKZQI3Q4MCDQ6ZZFFA5CNFSM4KJNEU32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IHQHGYA">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJ2IZ45P5EPZYS4OEZ3Q6ZZFFANCNFSM4KJNEU3Q">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAIOWJ2WOKQ6KOYHRQDBU43Q6ZZFFA5CNFSM4KJNEU32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IHQHGYA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/issues/2424?email_source=notifications\u0026email_token=AAIOWJZGM7UJMKZQI3Q4MCDQ6ZZFFA5CNFSM4KJNEU32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IHQHGYA",
"url": "https://github.com/geany/geany/issues/2424?email_source=notifications\u0026email_token=AAIOWJZGM7UJMKZQI3Q4MCDQ6ZZFFA5CNFSM4KJNEU32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IHQHGYA",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>