Bug 99473 - Add shebang magic for gjs JavaScript files
Summary: Add shebang magic for gjs JavaScript files
Status: RESOLVED FIXED
Alias: None
Product: shared-mime-info
Classification: Unclassified
Component: freedesktop.org.xml (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: Shared Mime Info group
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-20 12:22 UTC by Philip Withnall
Modified: 2017-01-20 13:47 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Add application/x-executable as a supertype of application/ecmascript (888 bytes, patch)
2017-01-20 12:22 UTC, Philip Withnall
Details | Splinter Review
Add shebang magic for gjs JavaScript files (2.71 KB, patch)
2017-01-20 12:22 UTC, Philip Withnall
Details | Splinter Review

Description Philip Withnall 2017-01-20 12:22:09 UTC
Patch to do that, plus another small cleanup, attached. Includes test cases.
Comment 1 Philip Withnall 2017-01-20 12:22:12 UTC
Created attachment 129065 [details] [review]
Add application/x-executable as a supertype of application/ecmascript

Just like Python.
Comment 2 Philip Withnall 2017-01-20 12:22:15 UTC
Created attachment 129066 [details] [review]
Add shebang magic for gjs JavaScript files

When writing scripts with gjs, it’s possible to write a program with no
`.js` suffix, but with a shebang line which invokes gjs. Add some magic
to detect that as application/x-javascript.
Comment 3 Bastien Nocera 2017-01-20 12:27:51 UTC
Comment on attachment 129066 [details] [review]
Add shebang magic for gjs JavaScript files

Review of attachment 129066 [details] [review]:
-----------------------------------------------------------------

::: freedesktop.org.xml.in
@@ +2391,5 @@
> +      <match type="string" value='eval \"exec /bin/gjs' offset="0"/>
> +      <match type="string" value="#!/usr/bin/gjs" offset="0"/>
> +      <match type="string" value="#! /usr/bin/gjs" offset="0"/>
> +      <match type="string" value='eval \"exec /usr/bin/gjs' offset="0"/>
> +      <match type="string" value="#!/usr/local/bin/gjs" offset="0"/>

Why /usr/local as well? Where would it apply?
Comment 4 Philip Withnall 2017-01-20 13:01:25 UTC
(In reply to Bastien Nocera from comment #3)
> Comment on attachment 129066 [details] [review] [review]
> Add shebang magic for gjs JavaScript files
> 
> Review of attachment 129066 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: freedesktop.org.xml.in
> @@ +2391,5 @@
> > +      <match type="string" value='eval \"exec /bin/gjs' offset="0"/>
> > +      <match type="string" value="#!/usr/bin/gjs" offset="0"/>
> > +      <match type="string" value="#! /usr/bin/gjs" offset="0"/>
> > +      <match type="string" value='eval \"exec /usr/bin/gjs' offset="0"/>
> > +      <match type="string" value="#!/usr/local/bin/gjs" offset="0"/>
> 
> Why /usr/local as well? Where would it apply?

I copied the magic matches from the Python rule (and changed `python` to `gjs`), since I think they’re fairly analogous.
Comment 5 Bastien Nocera 2017-01-20 13:47:54 UTC
Attachment 129065 [details] pushed as 8d771b2 - Add application/x-executable as a supertype of application/ecmascript
Attachment 129066 [details] pushed as c8d957d - Add shebang magic for gjs JavaScript files


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.