GNOME Bugzilla – Bug 699784
Allow inspecting the run program from a module
Last modified: 2013-05-07 16:16:00 UTC
While fixing bug 699432, I noticed that ARGV[0] does not include the filename as it would be expected by the usual meaning of ARGV, so the trick of looking at the spawned program to see if it lies in the current directory is broken. So I thought that, like C has program_invocation_name, gjs could have System.programInvocationName, containing the filename of the launched script. See patches.
Created attachment 243428 [details] [review] Expose the launched binary to JS Usually in various languages the launched program is available as ARGV[0], but in the gjs case, ARGV only contains command line arguments, so we need a separate property to retrieve the launched script. This is now exposed as System.programInvocationName. The use case is allowing package.js to determine if the app is launched from the source without hacks.
Created attachment 243429 [details] [review] Add some versioning properties to System To allow dynamic checks for new API and features, expose the GJS and JS version on the System module. For additional convenience, the gjs version is provided as a number that can be directly comparated to a reference value.
Review of attachment 243428 [details] [review]: OK. ::: gjs/console.c @@ +98,2 @@ if (js_version != NULL) source_js_version = js_version; We should probably remove js-version support at some point. ::: modules/system.c @@ +161,3 @@ + g_object_get(gjs_context, + "program-name", &program_name, + NULL); Hm, not the biggest fan of this, but OK.
Review of attachment 243429 [details] [review]: I don't think JS version is a great idea. It's API that we really should be removing, as upstream is removing it too.
Created attachment 243465 [details] [review] Add a version property to System To allow dynamic checks for new API and features, expose the GJS version in the System module. For additional convenience, it is provided as a number (major * 10000 + minor * 100 + micro) that can be directly comparated to a reference value.
Review of attachment 243465 [details] [review]: ::: installed-tests/test/js/testSystem.js @@ +13,3 @@ +function testVersion() { + JSUnit.assertEquals("1.8", System.jsVersion); Did you not run the tests?
Created attachment 243502 [details] [review] Add a version property to System To allow dynamic checks for new API and features, expose the GJS version in the System module. For additional convenience, it is provided as a number (major * 10000 + minor * 100 + micro) that can be directly comparated to a reference value. I did run the test suite, but only after a number of other changes, so I forgot to submit the fixed version. Sorry.
Review of attachment 243502 [details] [review]: OK.
Attachment 243428 [details] pushed as 47e06c7 - Expose the launched binary to JS Attachment 243502 [details] pushed as aab113e - Add a version property to System