From 125e80154d7d8f9588d3088c161ae5557656d9ef Mon Sep 17 00:00:00 2001 From: zhuyaliang <15132211195@163.com> Date: Sun, 4 Jul 2021 21:53:21 +0800 Subject: Use absolute path g_get_home_dir replaces "~/" --- mate-panel/panel-run-dialog.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mate-panel/panel-run-dialog.c') diff --git a/mate-panel/panel-run-dialog.c b/mate-panel/panel-run-dialog.c index f2be5ec0..b0f21829 100644 --- a/mate-panel/panel-run-dialog.c +++ b/mate-panel/panel-run-dialog.c @@ -332,6 +332,9 @@ command_is_executable (const char *command, char ***argvp) { gboolean result; + GRegex *regex = NULL; + gsize argv_len; + g_autofree gchar *home_path = NULL; char **argv; char *path; int argc; @@ -341,6 +344,18 @@ command_is_executable (const char *command, if (!result) return FALSE; + regex = g_regex_new ("^~/", 0, 0, NULL); + argv_len = g_strv_length (argv); + home_path = g_build_filename (g_get_home_dir (), "/", NULL); + for (gsize i = 0; i < argv_len; i++) + { + gchar *tmp_argv = NULL; + + tmp_argv = g_regex_replace_literal (regex, argv[i], -1, 0, home_path, 0, NULL); + g_free (argv[i]); + argv[i] = tmp_argv; + } + g_regex_unref (regex); path = g_find_program_in_path (argv[0]); if (!path) { -- cgit v1.2.1