On Jan 19, 2008 2:25 AM, bill purvis <[EMAIL PROTECTED]> wrote:
>
> On Saturday 19 January 2008, Ondrej Certik wrote:
> > On Jan 19, 2008 7:38 AM, Ondrej Certik <[EMAIL PROTECTED]> wrote:
> > > On Jan 18, 2008 10:00 PM, Georg Grafendorfer
> > >
> > > <[EMAIL PROTECTED]> wrote:
> > > > Michael,
> > > > OK, i'm already a bit confused, and i don't know any more what your
> > > > requesting exactly, so i will repeat some things:
> > > >
> > > > The file with the name ./example.sage
> > > > #!/home/georg/Daten/.System/bin/sage/sage -python
> > > > import sys
> > > >
> > > > gives me that strange mouse behaviour where the mouse pointer changes
> > > > to a cross (but not this "X-cross" known from pure X-Window) and
> > > > clicking on the 3 mouse buttons brings me back to the command line with
> > > > no output at all, this is because of the "import sys" line, without
> > > > this line nothing happens (just back to the next command line prompt).
> > >
> > > This made me curious, becuase I also use Debian (sid) and I get the
> > > exact same behaviour
> > > as you do and I wasn't able to figure out where the problem is in the
> > > last 10 minutes. Need to go now.
> >
> > ok, this works:
> >
> Case 1:
> > $ cat t.py
> > #!/bin/sh /home/ondra/ext/sage/sage
> > import sys
> > $ ./t.py
> > $
> >
> > And this doesn't:
> >
> Case 2:
> > $ cat t.py
> > #!/home/ondra/ext/sage/sage
> > import sys
> > $ ./t.py
> >
> > (I get the cross - which means that it's bash, who is executing that file
> > btw)
> >
> Case 3:
> > $ cat t.py
> > #!/bin/sh /home/ondra/ext/sage/sage -python
> > import sys
> > $ ./t.py
> > /bin/sh: /home/ondra/ext/sage/sage -python: No such file or directory
> >
> >
> > So I don't know. But it must be something stupid - I bet this used to
> > work for me before.
> >
> > Ondrej
> I just tried this under Ubuntu.
> Case 1 works
>
> Case 2 outputs
> ./t.py: line 2: import: command not found
>
> Case 3 behaves as yours.
>
> My 2p: My understanding of the #! convention is that the line is split
> up into three parts:
> #!
> <program name>
> <argument(s)>
> The <program name> must be an executable PROGRAM, not a script.
> The <argument(s) gets treated as a single string.
>
> This would explain my behaviour. Don't know what Debian does in case 2,
> Ubuntu seems to just ignore the first line if it's not a true executable
> and executes the rest of the file with /bin/sh.

I just posted a patch related to this discussion here
   http://trac.sagemath.org/sage_trac/ticket/1789

I think the upshot of the entire discussion above is (or should be) to use

  #!/usr/bin/env sage

instead of

     #!/usr/bin/env sage -python

This assumes sage is in your path -- and indeed it should be if you want
to write portable scripts.

The second form above, e.g.,


     #!/usr/bin/env sage -python

only works on OS X.  The first form, e.g.,

     #!/usr/bin/env sage

works on both OS X and linux.  Both are equivalent in behavior on OS X.

 -- william

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to