After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 584560 - Rename gjs-console to gjs and add support for shebang
Rename gjs-console to gjs and add support for shebang
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2009-06-01 21:56 UTC by David Zeuthen (not reading bugmail)
Modified: 2009-08-01 01:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add support for UNIX shebang (5.86 KB, patch)
2009-06-02 01:32 UTC, David Zeuthen (not reading bugmail)
none Details | Review
updated patch (2.02 KB, patch)
2009-06-02 02:39 UTC, David Zeuthen (not reading bugmail)
committed Details | Review
Bug 584560 - Add symbolic link from gjs to gjs-console in $(bindir) (683 bytes, patch)
2009-07-21 14:30 UTC, Colin Walters
committed Details | Review

Description David Zeuthen (not reading bugmail) 2009-06-01 21:56:00 UTC
To make it easier to write gjs apps, I propose that

 1. gjs-console is renamed to gjs

 2. shebang is added so things like

     #!/usr/bin/gjs
     // javascript code follows

    work as one would expect.
Comment 1 Havoc Pennington 2009-06-01 22:23:13 UTC
Sounds good to me.
Comment 2 David Zeuthen (not reading bugmail) 2009-06-02 01:32:26 UTC
Created attachment 135782 [details] [review]
Add support for UNIX shebang

Here's a patch to handle UNIX shebang.

It's more complicated to rename gjs-console to gjs since the gjs/ directory is kinda in the way :-/
Comment 3 Havoc Pennington 2009-06-02 02:21:29 UTC
well, if we reform all those pesky srcdir=builddir people there's no problem ;-)

        s = strstr (script, "\n");
        if (s != NULL) {
            len -= (s - script);

should subtract one more "len" to also chop the newline? or do I have it wrong?

       g_debug ("script = '%s'", script);

don't want to leave these in here

If gjs_context_eval() just stripped #! first line, some of the cut-and-pastes here could be cleaned up, which might be nice. Maybe all of them if we just don't allow #! in imported modules, which seems fine to me.
Comment 4 David Zeuthen (not reading bugmail) 2009-06-02 02:39:44 UTC
Created attachment 135785 [details] [review]
updated patch

(In reply to comment #3)
> well, if we reform all those pesky srcdir=builddir people there's no problem
> ;-)

Heh. We could also just create a hardlink in install-exec-hook. I mean, you probably want the gjs-console for compat reasons.

> 
>         s = strstr (script, "\n");
>         if (s != NULL) {
>             len -= (s - script);
> 
> should subtract one more "len" to also chop the newline? or do I have it wrong?
> 
>        g_debug ("script = '%s'", script);
> 
> don't want to leave these in here
> 
> If gjs_context_eval() just stripped #! first line, some of the cut-and-pastes
> here could be cleaned up, which might be nice. Maybe all of them if we just
> don't allow #! in imported modules, which seems fine to me.

Yeah, that sounds easier. Updated patch attached. This also includes a fix for the off-by-one bug pointed out above.
Comment 5 Havoc Pennington 2009-06-02 21:46:29 UTC
Looks good to me.
Comment 6 David Zeuthen (not reading bugmail) 2009-06-03 17:41:22 UTC
Committed, thanks. Keeping the bug open for the renaming stuff.
Comment 7 Colin Walters 2009-07-21 14:30:07 UTC
Created attachment 138911 [details] [review]
Bug 584560 - Add symbolic link from gjs to gjs-console in $(bindir)

We'd like people to be able to type 'gjs' to run.
Comment 8 Lucas Rocha 2009-08-01 01:29:30 UTC
(In reply to comment #7)
> Created an attachment (id=138911) [edit]
> Bug 584560 - Add symbolic link from gjs to gjs-console in $(bindir)
> 
> We'd like people to be able to type 'gjs' to run.

Makes sense. Pushed. 

Comment 9 Lucas Rocha 2009-08-01 01:32:14 UTC
I guess this bug can be closed now. Feel free to reopen if you think there's something still missing.