Next: , Previous: , Up: Invocation   [Contents][Index]


4.2 Shebang invocation

The rep interpreter also supports “Shebang”, or ‘#!’ interpreter invocation, i.e. if the first line of an executable text file contains ‘#!prog’, the program prog is used to execute the script, using the operating system’s support.

However with this method, the PATH environment variable is not searched for the location of the interpreter, and thus the full file name of the rep interpreter program must be hard-coded into the script.

To work around this problem rep supports a slightly different method of invocation; first look at this example:

#!/bin/sh
exec rep "$0" "$@"
!#

;; Lisp code follows…

If the first two characters of a loaded Lisp file are ‘#!’, then everything is treated as a comment until the first occurrence of the string ‘!#’. This allows the first part of the script to be executed as a shell script invoking the rep interpreter.