[squeak-dev] [ANN] DoItFirst command line goodie on SqueakSource

K K Subbu kksubbu.ml at gmail.com
Mon Dec 7 08:13:12 UTC 2020

On 07/12/20 1:40 am, David T. Lewis wrote:
> Tim's script starts with:
> #!/usr/bin/squeak /home/pi/Squeak/TPR-Squeak5.3-18560.image
> On my computer, the executable script for running Squeak VMs is
> called /usr/local/bin/run rather than /usr/bin/squeak, and the
> particular image that I am running at the moment is called squeak.12.image,
> so I edited the line in my script file to look like this:
> #!/usr/local/bin/spur64 squeak.12.image
> So now the FibonacciTestScript.st file is a Unix executable shell
> script, and I can run it like this:
> $ ./FibonacciTestScript.st

On Linux, one can use the binfmt_misc (see update-binfmts(8)) to shorten 
launch times for interpreters like squeak. This kernel module can match 
command files with their interpreter based on extension or embedded code 
patterns. Python and Java already use this feature. update-binfmts can 
install, display, find, disable, enable or remove interpreters and their 
scripts/images based on file extensions or embedded magic codes.

Executing .st scripts will require two registrations. One to match .st 
to its image and a second one to match the image to its vm.

1. To match .st to image, register a magic pattern with the binfmt_misc 
feature along with the specific image to be launched:

$ sudo update-binfmts --install squeak5-64 
/var/squeak/squeak5-3-64bit.image --magic '"#spur64"' --offset 0

This will execute all .st files beginning with "spur64" with the given 
$ chmod +x ./foo-bar.st /var/squeak/squeak5.3-64bit.image
$ head -1 ./foo-bar.st

Now the command
$ ./foo-bar.st arg1 arg2
will be equivalent to:
$ /var/squeak/squeak5.3-64bit.image ./foo-bar.st arg1 arg2

2. Register another pattern to match .image to spur64 interpreter. Then 
the line is equivalent to:

$ /usr/local/bin/spur64 /var/squeak/squeak5.3-64bit.image ./foo-bar.st 
arg1 arg2

Registration is a one-time effort. Because the matching and loading is 
done in a kernel module, the startup time is reduced. This trick can be 
useful on platforms like RPi.

HTH .. Subbu

More information about the Squeak-dev mailing list