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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2786>
This commit is contained in:
Florian Müllner 2023-05-30 14:41:36 +02:00
parent 80ac32a268
commit 38c9364acc

View File

@ -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,
"<main>",
&status,