[squeak-dev] Running Squeak fro ma unix shell script file with #! squeak...

David T. Lewis lewis at mail.msen.com
Mon May 6 23:41:03 UTC 2019

On Mon, May 06, 2019 at 03:53:30PM -0700, tim Rowledge wrote:
> The remaining problem is that any attempt to include any option (say #!/usr/bin/squeak -fullscreen --) confuses things as it leads to the vm being unable to recognise any of the options. 

This is a tricky one, and unfortunately it is not something that you can easily work around.

What is happening here is is that '-fullscreen --' is being passed to the VM as a single
argument with an embedded space.

Different unix systems may implement this differently, and I found a good summary
at https://www.in-ulm.de/~mascheck/various/shebang/ (scroll down and look for the
section on "showargs").

The most common implementation is for the unix exec machinery to take the first
part of the shebang line (/usr/bin/squeak) and let it be argv[0], then any
remaining stuff on the line is argv[1], and the name of the invoking script
(./hello.sq) is passed as argv[2]. This is just enough cleverness to allow the
script (/usr/bin/squeak or /bin/sh or whatever) to receive a single argument
(such as --) and figure out what to do from there.

Anything more clever than this would require an additional level of option parsing
that would normally be performed by a shell (such as bash). The exec mechanism
makes no attempt to do that.

> The weird bit is that the final command is -
> LD_LIBRARY_PATH=/usr/lib/squeak/5.0-201610101924:/lib/arm-linux-gnueabihf:/lib:/usr/lib/arm-linux-gnueabihf:/usr/lib: /usr/lib/squeak/5.0-201610101924/squeak -fullscreen /home/pi/Squeak/squeak.image ./HelloWorld.st

It all looks good, but the hidden "gotcha" that bites you here is that
'-fullscreen /home/pi/Squeak/squeak.image' is actually a single argument
token, even though it looks like it is two separate arguments.


More information about the Squeak-dev mailing list