From 38c9364acce638fb07ffd7962388d8c7df43b55f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 30 May 2023 14:41:36 +0200 Subject: [PATCH] portalHelper: Stop using non-default ARGV vector If gjs itself defines ARGV, it only holds the arguments that are passed on to the script, and javascript code should combine the programName and ARGV (or the newer programArgs) when it needs a C-style argv array. Do the same in the portal-helper process instead of passing along the original C argv, to avoid confusion when accessing the arguments from javascript. Part-of: --- src/gnome-shell-portal-helper.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/gnome-shell-portal-helper.c b/src/gnome-shell-portal-helper.c index a0bebb216..9e03a482d 100644 --- a/src/gnome-shell-portal-helper.c +++ b/src/gnome-shell-portal-helper.c @@ -18,23 +18,16 @@ main (int argc, char *argv[]) textdomain (GETTEXT_PACKAGE); context = g_object_new (GJS_TYPE_CONTEXT, + "program-name", *argv, "search-path", search_path, NULL); - if (!gjs_context_define_string_array(context, "ARGV", - argc, (const char**)argv, - &error)) - { - g_message("Failed to define ARGV: %s", error->message); - g_error_free (error); - g_object_unref (context); - - return 1; - } - + gjs_context_set_argv(context, argc - 1, (const char**)argv + 1); if (!gjs_context_eval (context, - "const Main = imports.portalHelper.main; Main.main(ARGV);", + "const Main = imports.portalHelper.main;" + "const {programInvocationName, programArgs} = imports.system;" + "Main.main([programInvocationName, ...programArgs]);", -1, "
", &status,