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 793657 - Interpreter mode: Can't pass target arguments
Interpreter mode: Can't pass target arguments
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: general
unspecified
Other All
: Normal minor
: 0.42
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2018-02-20 14:50 UTC by Michael 'Mickey' Lauer
Modified: 2018-05-22 16:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Sample (248 bytes, application/octet-stream)
2018-02-20 14:50 UTC, Michael 'Mickey' Lauer
  Details
Fix critical (921 bytes, patch)
2018-02-28 12:18 UTC, Michael 'Mickey' Lauer
committed Details | Review

Description Michael 'Mickey' Lauer 2018-02-20 14:50:30 UTC
Created attachment 368652 [details]
Sample

Vala behaves somewhat erratic when being run in "interpreter" mode:

The attached sample prints out the arguments it has been passed via POSIX main.

With Vala master (ref c424722da4eafd9d75fff3220c764a11566d5dc0) it doesn't seem to be possible to call it as expected. There are two issues:

1.) % vala --pkg=posix ./yo.vala                                                                                                         
(vala:45413): GLib-CRITICAL **: g_strsplit: assertion 'string != NULL' failed

This is just cosmetics, hence a minor issue. However 

2.) % vala --pkg=posix ./yo.vala Test
error: Test not found

I would have expected that every command line argument after the "script" is passed to the target. It looks though as the compiler intercepts the 'Test' argument, hence it's not possible to call it at all. Consequently, calling it via ./yo.vala, which should work as well since the sample is using a #! as first line, fails as well.
Comment 1 Rico Tzschichholz 2018-02-20 16:19:10 UTC
For reference https://git.gnome.org/browse/vala/commit/?id=0e45b19dfabce1b2f04733d7ec6eb02d6692b549

The critical needs to be fixed though.
Comment 2 Michael 'Mickey' Lauer 2018-02-28 12:18:22 UTC
Created attachment 369094 [details] [review]
Fix critical
Comment 3 Michael 'Mickey' Lauer 2018-03-01 22:12:27 UTC
For some reason this is still not what I'm after. My ultimate goal is to provide a workflow similar to scripting languages:

1.) Write a program with a #! line
2.) chmod a+rx it
3.) Run it and pass arguments via ./program arg1 arg2 arg3

With --run-args I though I could do:

=============================================
#!/usr/bin/env vala --pkg=posix --run-args

int main( string[] args )
{
        foreach ( var string in args )
        {
                message( @"arg = $string" );
        }
        return 0;
}
=============================================

But I still get:

% ./test.vala a b c                                                                                                                  mickey@sandstein
error: a not found
error: b not found
error: c not found
Comment 4 Rico Tzschichholz 2018-03-02 08:04:03 UTC
commit a9996877480287308d8273c8469c87fa48b3a3ea (HEAD -> master, origin/staging, staging)
Author: Dr. Michael Lauer <mickey@vanille-media.de>
Date:   Wed Feb 28 13:14:53 2018 +0100

    compiler: fix critical when vala is called without run args
    
    https://bugzilla.gnome.org/show_bug.cgi?id=793657
Comment 5 GNOME Infrastructure Team 2018-05-22 16:00:43 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/618.