#Smalltalk ==                     "start of -*- Smalltalk -*- comment
exec gst "$0" -aQ $@              # end  of     Smalltalk     comment"!

"======================================================================
|
|   Example of starting a Smalltalk program from the shell
|
|   $Revision: 1.7.5$
|   $Date: 2000/05/28 16:56:52$
|   $Author: pb$
|
 ======================================================================"


"======================================================================
|
| Copyright 1988-92, 1994-95, 1999, 2000 Free Software Foundation, Inc.
| Written by Paolo Bonzini.
|
| This file is part of GNU Smalltalk.
|
| GNU Smalltalk is free software; you can redistribute it and/or modify it
| under the terms of the GNU General Public License as published by the Free
| Software Foundation; either version 2, or (at your option) any later version.
| 
| GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
| FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
| details.
| 
| You should have received a copy of the GNU General Public License along with
| GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
| Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
|
 ======================================================================"

" The first two lines above needs some explanations.
|
| The first line is nothing more than a comment to bash, so the first thing
| bash sees is the second line, up to the hash sign: an `exec' command
| which starts gst. And nothing more, since the child shell's execution
| stops after it launches GNU Smalltalk.
| 
| Instead, what Smalltalk sees after you delete the Smalltalk comments, is
| `#Smalltalk == $0!': a valid expression which is executed but produces no
| visible results.
| 
| Also, note that you can put the -*- MODE -*- signature used by Emacs on the
| first line.
|
| This technique should be used with script that you expect to take at least a
| few seconds to run, since Smalltalk's startup is not exactly lightning fast.
| 
| Since we are talking about Unix, I'll put here some more magic:
|
| a) add this to your /usr/share/magic file:
|  
|    # GNU Smalltalk image, starting at version 1.6.2
|    0	string		GSTIm\0\0	GNU Smalltalk image
|
| b) echo these two to /proc/sys/fs/binfmt_misc/register under Linux (maybe
| from a startup script) -- nothing goes before the first colons, and
| remember to use double backslashes from the shell!):
|
|    :GSTIm_Magic:M::GSTIm\x0\x0::/usr/bin/gst-startimage
|    :GSTIm_Ext:E::.im::/usr/bin/gst-startimage
|
| putting this in /usr/bin/gst-startimage
|
|    #! /bin/sh
|    exec gst -I $1
"

stdout
    nl;
    nextPutAll: 'the arguments were ';
    print: Smalltalk arguments;
    nl; nl!

