#11790: `sage --sh -c ...` shouldn't print [that many] messages
-----------------------+----------------------------------------------------
   Reporter:  leif     |          Owner:                                        
                   
       Type:  defect   |         Status:  needs_review                          
                   
   Priority:  minor    |      Milestone:  sage-4.7.2                            
                   
  Component:  scripts  |       Keywords:  subshell commands sage-sage 
environment batch mode stdout
Work_issues:           |       Upstream:  N/A                                   
                   
   Reviewer:           |         Author:  John Palmieri                         
                   
     Merged:           |   Dependencies:  #11866                                
                   
-----------------------+----------------------------------------------------

Comment(by leif):

 Replying to [comment:4 jhpalmieri]:
 > Replying to [comment:3 leif]:
 > > The code testing for `-c` could be moved up, since everything else (in
 the `case ... esac`) is useless in this case .
 >
 > Well, if you're running "sage --sh CMD", it should matter whether you're
 running "bash" or "bash --norc", right?  The `case ... esac` stuff sets
 shell options like `--norc` in addition to the prompt, and I think we want
 this.

 Any shell called with `-c` '''must not''' execute any rc files.

 [[BR]]

 > > Also, if `exec` returns, this means an error, so we could print some
 according message in this case (although ''hopefully''^TM^ the shell
 itself did).
 >
 > So are you suggesting not checking the status at all? Like this:
 {{{
 #!diff
 diff --git a/sage-sage b/sage-sage
 --- a/sage-sage
 +++ b/sage-sage
 @@ -518,8 +518,8 @@ PS1="SAGE_ROOT=${SAGE_ROOT}
      esac
      if [ "$1" = '-c' ]; then
         exec $SHELL_NAME $SHELL_OPTS "$@"
 -       status=$?
 -       exit $status
 +       echo "An error seems to occurred." 1>&2
 +       exit 1
      fi
      # -c is not the first option, so print informative messages...
      echo "" 1>&2
 }}}
 > I could probably come up with a more cryptic message, though.

 :)

 I rather meant something like
 {{{
 #!sh
     ...
     SHELL_NAME=`basename $SHELL`

     if [ "$1" = "-c" ]; then
         exec "$SHELL_NAME" "$@"
         # If 'exec' returns, an error occurred:
         status=$?
         echo >&2 "Fatal error: 'exec \"$SHELL_NAME\" \"$@\"' failed!"
         exit $status # Always non-zero, but return the code the shell
 gave.
     fi

     case $SHELL_NAME in
     ...
 }}}

 [[BR]]

 Btw., any reason to call `$SHELL_NAME` instead of `$SHELL`?

 The latter would IMHO be correct.

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