Squeak scripts in UNIX

Tony Garnock-Jones tonyg at lshift.net
Tue Feb 13 22:10:15 UTC 2007


Lex Spoon wrote:
>   #!/bin/sh
>   exec squeak -headless -- "$0" "$@"
>   !#

An alternative which may not require changes to any parser is something
like the following:

  "exec" "squeak" "-headless" "--" "$0" "$@"

This is a pun of sorts: in Squeak, it's a sequence of five comments at
the start of the script; in shell, it's a sequence of words that happen
to be harmlessly redundantly quoted.

I've not tested that particular variant, but I have used a similar
punning trick in Scheme, where ';' introduces a single line comment:

  "true"; exec /path/to/scheme/interpreter "$0" "$@"
  (rest of scheme program)

To the shell, this is an execution of /bin/true followed by a
replacement of the current process by a scheme interpreter; to Scheme,
the first line is a self-evaluating string expression which happens to
have a comment on it, and the rest of the file is the actual program.

Regards,
  Tony




More information about the Squeak-dev mailing list