#11602: install_scripts should use "$@" instead of $*
----------------------+-----------------------------------------------------
   Reporter:  Stefan  |          Owner:  jason                            
       Type:  defect  |         Status:  new                              
   Priority:  minor   |      Milestone:  sage-4.7.2                       
  Component:  misc    |       Keywords:  install_scripts, hg, command line
Work_issues:          |       Upstream:  N/A                              
   Reviewer:          |         Author:                                   
     Merged:          |   Dependencies:                                   
----------------------+-----------------------------------------------------
Changes (by leif):

 * cc: drkirkby, leif (added)


Comment:

 Yep, from `sage/misc/dist.py`:
 {{{
 #!python

             if os.path.exists(target):
                 print "The file '%s' already exists; not adding
 shortcut"%(target)
             else:
                 o = open(target,'w')
                 o.write('#!/bin/sh\n')
                 o.write('sage -%s $*\n'%c)
                 print "Created script '%s'"%target
                 os.system('chmod a+rx %s'%target)
 }}}

 So this should be `o.write('sage -%s "$@"\n'%c)`.

 At first glance, there are some other things that should be changed:

  * The generated file isn't explicitly closed after it was written (i.e.,
 add `o.close()`).
  * `which` isn't portable; one should use the shell built-in `command -v
 ...`.

 Moreover:

  * As long as the generated scripts are trivial, using `#!/bin/sh` is ok;
 for more complex ones, this should be `#!/usr/bin/env bash` since on some
 systems `/bin/sh` is very limited or even broken. I wouldn't change it
 ''here'' though, since `/bin/sh` is usually a light-weight shell and
 therefore faster.
  * I wonder if it's really desirable to not install shortcuts for programs
 shipped with Sage of which '''some''' system-wide version is in the
 current `PATH`. We could at least add a boolean parameter (defaulting to
 `False`) to override this behaviour.

 Btw, you don't have to provide a doctest when fixing this; we'll just
 review the changes.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11602#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to