#11790: `sage --sh -c ...` shouldn't print [that many] messages
------------------------------+---------------------------------------------
   Reporter:  leif            |          Owner:                                 
                          
       Type:  defect          |         Status:  needs_review                   
                          
   Priority:  blocker         |      Milestone:  sage-5.0                       
                          
  Component:  scripts         |       Keywords:  subshell commands sage-sage 
environment batch mode stdout
Work_issues:                  |       Upstream:  N/A                            
                          
   Reviewer:  Jeroen Demeyer  |         Author:  John Palmieri                  
                          
     Merged:                  |   Dependencies:  #12647                         
                          
------------------------------+---------------------------------------------
Changes (by jdemeyer):

  * status:  needs_work => needs_review


Old description:

> Currently, we have
> {{{
> #!sh
> $ ./sage --sh -c "echo Hello"
>
> Starting subshell with Sage environment variables set.
> Be sure to exit when you are done and do not do anything
> with other copies of Sage!
>
> Bypassing shell configuration files ...
>
> Hello
> Exited Sage subshell.
> $
> }}}
> which is IMHO odd.
>
> And it's inconvenient if one wants to further process the output of some
> command run in a Sage subshell.
>
> In `spkg/bin/sage`, we have:
> {{{
> #!sh
> if [ "$1" = '-sh'  -o "$1" = '--sh' ]; then
>     # AUTHORS:
>     #   Carl Witty and William Stein: initial version
>     #   Craig Citro: add options for not loading profile
>     cd "$CUR"
>     shift
>     echo ""
>     echo "Starting subshell with Sage environment variables set."
>     echo "Be sure to exit when you are done and do not do anything"
>     echo "with other copies of Sage!"
>     echo ""
>     SHELL_NAME=`basename $SHELL`
>     echo "Bypassing shell configuration files ..."
>     echo
>
>     ...
>
>     $SHELL_NAME $SHELL_OPTS "$@"
>
>     status=$?
>     echo "Exited Sage subshell."
>     exit $status
> fi
> }}}
>
> So I'd propose to change `sage` to not print ''any'' messages if there
> are any further arguments to `sage --sh`.
>
> Alternatively, all (or a reduced set of) messages should at least go to
> `stderr` instead of `stdout`, perhaps regardless of whether `-c` was
> specified or not.
>
> In addition, if we dropped the "`Exited Sage subshell.`" (at least in the
> case of `-c`), we could (or should) also use
> {{{
> #!sh
>     exec $SHELL_NAME $SHELL_OPTS "$@"
> }}}
>
> (Actually, `exec` should be used in a couple of Sage commands which don't
> need any "post-processing", e.g. by `sage`.)
>
> '''Apply''' [attachment:11790_sage_sh.patch] to the SAGE_ROOT repository.

New description:

 Currently, we have
 {{{
 #!sh
 $ ./sage --sh -c "echo Hello"

 Starting subshell with Sage environment variables set.
 Be sure to exit when you are done and do not do anything
 with other copies of Sage!

 Bypassing shell configuration files ...

 Hello
 Exited Sage subshell.
 $
 }}}
 which is IMHO odd.

 And it's inconvenient if one wants to further process the output of some
 command run in a Sage subshell.

 In `spkg/bin/sage`, we have:
 {{{
 #!sh
 if [ "$1" = '-sh'  -o "$1" = '--sh' ]; then
     # AUTHORS:
     #   Carl Witty and William Stein: initial version
     #   Craig Citro: add options for not loading profile
     cd "$CUR"
     shift
     echo ""
     echo "Starting subshell with Sage environment variables set."
     echo "Be sure to exit when you are done and do not do anything"
     echo "with other copies of Sage!"
     echo ""
     SHELL_NAME=`basename $SHELL`
     echo "Bypassing shell configuration files ..."
     echo

     ...

     $SHELL_NAME $SHELL_OPTS "$@"

     status=$?
     echo "Exited Sage subshell."
     exit $status
 fi
 }}}

 So I'd propose to change `sage` to not print ''any'' messages if there are
 any further arguments to `sage --sh`.

 Alternatively, all (or a reduced set of) messages should at least go to
 `stderr` instead of `stdout`, perhaps regardless of whether `-c` was
 specified or not.

 In addition, if we dropped the "`Exited Sage subshell.`" (at least in the
 case of `-c`), we could (or should) also use
 {{{
 #!sh
     exec $SHELL_NAME $SHELL_OPTS "$@"
 }}}

 (Actually, `exec` should be used in a couple of Sage commands which don't
 need any "post-processing", e.g. by `sage`.)

 '''Apply''' [attachment:11790_sage_sh.patch] and
 [attachment:11790_review.patch] to the SAGE_ROOT repository.

--

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