[Distutils] easy_install adds bad interpreter shebang to installed scripts

Jean-Paul Calderone exarkun at divmod.com
Thu Dec 18 16:40:03 CET 2008


On Thu, 18 Dec 2008 16:20:28 +0100, Felix Schwarz <felix.schwarz at web.de> wrote:
>Phillip J. Eby schrieb:
>>At 10:17 PM 12/17/2008 +0100, Felix Schwarz wrote:
>>>Ian Bicking schrieb:
>>>>Does this work?
>>>>#!/usr/bin/env "/path/to/weird path/python"
>>>
>>>No (at least not for me).
>>
>>Did you actually try that, as opposed to the version you showed before? 
>>There *is* a difference.
>
>Of course I tried. :-)
>I just tried again and it still does not work. However I noticed that it 
>works without any quoting for me too. Which I thought I tried before...
>
>So for me (using Fedora Linux with Python 2.5, nothing unusual) the solution 
>would be to add
>/usr/bin/env <unquoted path>
>
>Probably this is the way to go forward. Let's see if the behavior is 
>different for BSDs (I have neither a Mac nor any BSD-based system available 
>right now).

OS X results (note, ~/foo exists and is a directory):

  neutron:~ exarkun$ cat > foobar.sh
  #!/Users/exarkun/foo bar/python
  print 'yes'
  neutron:~ exarkun$ chmod u+x foobar.sh 
  neutron:~ exarkun$ ./foobar.sh 
  -bash: ./foobar.sh: /Users/exarkun/foo: bad interpreter: Permission denied
  neutron:~ exarkun$ cat > foobar.sh
  #!/Users/exarkun/foo\ bar/python
  print 'yes'
  neutron:~ exarkun$ ./foobar.sh 
  -bash: ./foobar.sh: /Users/exarkun/foo\: bad interpreter: No such file or directory
  neutron:~ exarkun$ cat > foobar.sh
  #!"/Users/exarkun/foo bar/python"
  print "yes"
  neutron:~ exarkun$ ./foobar.sh 
  -bash: ./foobar.sh: "/Users/exarkun/foo: bad interpreter: No such file or directory
  neutron:~ exarkun$ cat > foobar.sh
  #!'/Users/exarkun/foo bar/python'
  print 'yes'
  neutron:~ exarkun$ ./foobar.sh 
  -bash: ./foobar.sh: '/Users/exarkun/foo: bad interpreter: No such file or directory
  neutron:~ exarkun$ cat > foobar.sh
  #!/usr/bin/env /Users/exarkun/foo bar/python
  print 'yes'
  neutron:~ exarkun$ ./foobar.sh 
  env: /Users/exarkun/foo: Permission denied
  neutron:~ exarkun$ cat > foobar.sh
  #!/usr/bin/env /Users/exarkun/foo\ bar/python
  print 'yes'
  neutron:~ exarkun$ ./foobar.sh 
  env: /Users/exarkun/foo\: No such file or directory
  neutron:~ exarkun$ cat > foobar.sh
  #!/usr/bin/env "/Users/exarkun/foo bar/python"
  print 'yes'
  neutron:~ exarkun$ ./foobar.sh 
  env: "/Users/exarkun/foo: No such file or directory
  neutron:~ exarkun$ cat > foobar.sh
  #!/usr/bin/env '/Users/exarkun/foo bar/python'
  print 'yes'
  neutron:~ exarkun$ ./foobar.sh 
  env: '/Users/exarkun/foo: No such file or directory
  neutron:~ exarkun$ 

Jean-Paul


More information about the Distutils-SIG mailing list