This is a file that can be executed as both a shell script and a Python script. Note the shebang is #!/bin/sh
, so the script is intended to be run as a shell script first. (I'm ignoring the -
argument, which would indicate that sh
should read from standard input instead of a file. I'm not quite sure what it's significance is here, as I've never seen a shebang written that way.)
The intended invocation is something like ./pox.py ...
or sh ./pox.py ...
The first line of the script is ''''true
, which after quote removal is the same as true
, so that command runs and does nothing except exit with success. The following lines are valid commands to determine which Python interpreter to use and what options to pass to the invocation. One of the three exec
commands
exec pypy/bin/pypy $OPT "$0" $FLG "$@"
exec python2.7 $OPT "$0" $FLG "$@"
exec python $OPT "$0" $FLG "$@"
will then execute the same file as a Python script, so the lines beginning with the second '''
are never seen by the shell (which is good, because the word started by the first '
is neither terminated with a final closing '
, nor would the string be a valid command if it were terminated). "$0"
is the name of the current file, and "$@"
represents the arguments to the script (which are ignored by the shell script except to pass on to the Python script, as shown here).
Once the script is run as a Python script, the line starting ''''true
is simply seen as the beginning of a doc string that will be ignored. The Python script proper is simply
from pox.boot import boot
if __name__ == '__main__':
boot()
As to why this all has to start with ''''true
? As a shell script, you need to have an even number of quotes to balance each other. However, ''''
alone would be an empty string that the shell would attempt to treat as a command, and there is no command whose name is the empty string. ''''true
, however, does result in a valid command.