sh: test: argument expected and /usr/bin/env

Jeff Epler jepler at unpythonic.net
Tue Nov 9 10:39:39 EST 2004


In the #!-line of a script, everything after the first (white?)space is
taken as the first argument to the named binary, and the filename of the
script is the second argument.  This is standard Unix behavior, nothing
Python-specific.

So your second #! is like executing
    /usr/bin/env "SHELL=/bin/bash python" yourscript.py
which probably causes /usr/bin/env to be invoked again with the same
arguments, indefinitely (because the command is a #!/usr/bin/env script)

You can set environment variables in Python.  Why not add
    import os
    os.environ['SHELL'] = "/bin/bash"
just below the #!-line?

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041109/1176d5de/attachment.sig>


More information about the Python-list mailing list