summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhuyaliang <[email protected]>2021-07-04 21:53:21 +0800
committerraveit65 <[email protected]>2021-08-03 22:26:45 +0200
commit125e80154d7d8f9588d3088c161ae5557656d9ef (patch)
tree3f8e49dc564254cc7824e758ad85afc29e0f2014
parent633f79b08e2f2fe5e4c3195b2a983fa56b027e0c (diff)
downloadmate-panel-125e80154d7d8f9588d3088c161ae5557656d9ef.tar.bz2
mate-panel-125e80154d7d8f9588d3088c161ae5557656d9ef.tar.xz
Use absolute path g_get_home_dir replaces "~/"
-rw-r--r--mate-panel/panel-run-dialog.c15
1 files changed, 15 insertions, 0 deletions
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) {