#4029: [with patch; needs work] sage-env kills the shell when called from 
"wrong"
directory
----------------------------+-----------------------------------------------
   Reporter:  dphilp        |       Owner:  mabshoff       
       Type:  defect        |      Status:  needs_work     
   Priority:  minor         |   Milestone:  sage-4.7       
  Component:  distribution  |    Keywords:  sage-env source
     Author:  Mike Hansen   |    Upstream:  N/A            
   Reviewer:                |      Merged:                 
Work_issues:                |  
----------------------------+-----------------------------------------------
Changes (by iandrus):

  * status:  needs_review => needs_work


Comment:

 You're right this won't be obsoleted by 10469, I was misremembering this
 ticket.  However, I am a little confused about what is actually wanted--
 because of the `$(exit)` link I thought we wanted to be able to execute
 `sage-env`.  I think the correct thing to do is change all of the exit's
 to return's since `sage-env` is meant to be sourced.  This means that any
 script which sources sage-env will have to check return status and exit
 rather than relying on `sage-env` to exit for it.

 I could only find `sage-sage`, `Makefile`, `sage-spkg`, and a `start-
 sage.sh` in the Mac app which source `sage-env` so we will have to change
 them to check the exit status, and `sage-sage` and `Makefile` already do.
 I talked with William and he said he doesn't know why it uses exit rather
 than having the calling script check the exit status.

 If we want/need to keep the current behavior of exiting, we could use a
 hack like
 {{{
 # Exit if not called interactively.  For some reason scripts sourcing
 # sage-env expect errors to exit them.  However this is evil for
 # interactive shells.
 case $- in
     *i*)    # interactive shell should return
         die=return;;
     *)      # non-interactive shell
         die=exit;;
 esac

 # ...
 # some error
 $die 1
 }}}
 to not exit the shell unless it's interactive.  Unfortunately I'm not sure
 how portable it is--I checked bash and zsh.

 ---

 What my previous hack does is try to return and if that fails (because it
 was executed instead of sourced) then it calls exit.  If it's only ever
 sourced (per #10469) then it would be better to change them all to return,
 since that's what my hack would do.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4029#comment:14>
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