GNOME Bugzilla – Bug 793657
Interpreter mode: Can't pass target arguments
Last modified: 2018-05-22 16:00:43 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.
For reference https://git.gnome.org/browse/vala/commit/?id=0e45b19dfabce1b2f04733d7ec6eb02d6692b549 The critical needs to be fixed though.
Created attachment 369094 [details] [review] Fix critical
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
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
-- 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.