problem executing python scripts in cygwin bash shell

Douglas Alan nessus at mit.edu
Sat Apr 7 16:39:24 EDT 2001


"John J. Lee" <phrxy at csv.warwick.ac.uk> writes:

>>> Aha!  Good idea.  Perhaps even better:

>>> #!/bin/sh

>>> temp = "$@ "
>>> //d/apps/Python20/python `cygpath -w $1` ${temp#* }

>> Good idea, but not quite right.  You really want:

>>   #!/bin/sh
>>
>>   exec //d/apps/Python20/python "`cygpath -w $1`" ${1+"$@"}

> Hmm, have you actually tried executing that?

No, I don't normally do Windoze, but your script has several problems:

   (1) There should be no spaces around the "=" in 

          temp = "$@ "

   (2) Your script will not work right if any of the arguments to the script
       has spaces in it.

   (3) It leaves an extra bash processes sitting around for no good
       reason while your python program is running.

Here's an update to my version that fixes the problem you pointed out:

   #!/bin/sh

   cp=`cygpath -w $1`
   shift   
   exec //d/apps/Python20/python "$cp" ${1+"$@"}

If you are using bash (as opposed to the Bourne shell) you can replace

   ${1+"$@"}

with 

   "$@"

if you are so inclined.

|>oug



More information about the Python-list mailing list