Files
gnome-shell/src/gnome-shell-portal-helper.c
Florian Müllner 38c9364acc 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>
2023-06-21 13:26:42 +02:00

46 lines
1.3 KiB
C

/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
#include "config.h"
#include <gjs/gjs.h>
#include <glib/gi18n.h>
int
main (int argc, char *argv[])
{
const char *search_path[] = { "resource:///org/gnome/shell", NULL };
GError *error = NULL;
GjsContext *context;
int status;
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
context = g_object_new (GJS_TYPE_CONTEXT,
"program-name", *argv,
"search-path", search_path,
NULL);
gjs_context_set_argv(context, argc - 1, (const char**)argv + 1);
if (!gjs_context_eval (context,
"const Main = imports.portalHelper.main;"
"const {programInvocationName, programArgs} = imports.system;"
"Main.main([programInvocationName, ...programArgs]);",
-1,
"<main>",
&status,
&error))
{
g_message ("Execution of main.js threw exception: %s", error->message);
g_error_free (error);
g_object_unref (context);
return status;
}
g_object_unref (context);
return 0;
}