help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Re: /bin/sh execution of st scripts.


From: Robert Collins
Subject: [Help-smalltalk] Re: /bin/sh execution of st scripts.
Date: Wed, 08 Sep 2004 15:01:25 +1000

On Tue, 2004-09-07 at 13:54 +0200, Paolo Bonzini wrote:

> >*) #!/bin line support: 
> >  rather than writing a wrapper script that calls gst with the right
> >packages & .st files to load, or that pipes stuff into gst, users just
> >create a file with #!/bin/env python at the top, and it just works. I'm
> >working on a patch to do this for gnu-smalltalk.
> >  
> >
> I can do this too, but send the patch when it is ready.  I'd like it to 
> be as little intrusive as possible, e.g. recognizing the sequence *only* 
> at the beginning of the file (in the lexer?).

Absolutely. My current plan is to edit primitive op 11 (thanks Bruce) to
remove the first line during file in, for the first file filed in, and
only when a global flag has been set.

>   A problem is that you 
> want to pass arguments but you cannot do
> 
> #! /bin/env gst -aQ
> 
> So in addition to supporting the shebang I'd install gst as both "gst" 
> and "gst-run", with the latter doing something like
> 
> new_argv = alloca (sizeof (char *) * (argc + 2));
> new_argv[0] = argv[0];
> new_argv[1] = argv[1];
> new_argv[2] = "-aQ";
> memcpy (new_argv + 3, argv + 2, sizeof (char *) * (argc - 1));
> gst_smalltalk_args (argc + 1, new_argv);
> 
> in main.c

What I was planning was to add a new argument 
-s --script     run smalltalk as a scripting language. This
                makes smalltalk file in the first file on the 
                command line, trimming the first line (#!/...)
                and pass all other arguments to through to the VM, as 
                if -a had been passed.

IMO this is better than having a different executable, because its then
under user control. 

The scripts would then be
#!/usr/bin/gst -Qs

or are you saying you can't pass parameters?
this:
===
#!/usr/bin/gst -Qa
===

works for me: it invokes a quiet gst interpreter on the command line. 

Actually that suggests another approach:
FileStream fileIn: (Smalltalk argument) skipHashBang: True

The only other thing needed, IIRC, is to get at argv[0] where the
scripts name will be.

Anyway, this is something I'd like to do for fun.. probably next
weekend.

Rob


-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]