#4644 - No new prompt when doing a ./sage -sh
#5507 - $ sage -sh -c "echo hi there" # does not work, but should
$ sage -sh -c -c "echo hi there" # works, but shouldn't
There is also a problem that "sage -sh" may pick up the user's
$PATH rather than the one defined in sage-env (which
is how I got into this issue).
The patch below fixes these three problems - but it may
not be what developers want. Specifically, it will set the
prompt to be "sage $" for all shells (with the exception of
csh which does not have a prompt environment variable and
so the prompt gets set to "%"). Note that with the patch
the prompt is NOT listing the current directory.
Do developers prefer that a sage-sub-shell prompt list
the current directory?
If so, I will have another think about this. If not, would
a kind person please check in the patch.
Mariah
--- sage-sage.old 2009-09-25 10:52:08.278703000 -0400
+++ sage-sage.new 2009-09-25 15:11:21.214214000 -0400
@@ -374,41 +374,37 @@
echo "with other copies of Sage!"
echo ""
SHELL_NAME=`basename $SHELL`
- if [ $# -eq 0 ]; then
- SHELL_OPTS=""
- else
- shift
- echo "Bypassing shell configuration files ..."
- echo
- # We must start a new shell with no .profile or .bashrc files
- # processed, so that we know our path is correct
- PS1="sage$ "
- export PS1
- case $SHELL_NAME in
- bash)
- SHELL_OPTS=" --norc"
- ;;
- csh)
- SHELL_OPTS=" -f"
- ;;
- ksh)
- SHELL_OPTS=" -p"
- ;;
- sh)
- SHELL_OPTS=" --norc"
- ;;
- tcsh)
- SHELL_OPTS=" -f"
- ;;
- zsh)
- SHELL_OPTS=" -f -d"
- ;;
- *)
- echo "Unknown shell: $SHELL!"
- echo "Exiting Sage."
- exit 1
- esac
- fi
+
+ echo "Bypassing shell configuration files ..."
+ echo
+ # We must start a new shell with no .profile or .bashrc files
+ # processed, so that we know our path is correct
+ PS1="sage$ "
+ export PS1
+ case $SHELL_NAME in
+ bash)
+ SHELL_OPTS=" --norc"
+ ;;
+ csh)
+ SHELL_OPTS=" -f"
+ ;;
+ ksh)
+ SHELL_OPTS=" -p"
+ ;;
+ sh)
+ SHELL_OPTS=" --norc"
+ ;;
+ tcsh)
+ SHELL_OPTS=" -f"
+ ;;
+ zsh)
+ SHELL_OPTS=" -f -d"
+ ;;
+ *)
+ echo "Unknown shell: $SHELL!"
+ echo "Exiting Sage."
+ exit 1
+ esac
$SHELL_NAME $SHELL_OPTS "$@"
echo Exited Sage subshell.
On Sat, Sep 26, 2009 at 6:04 AM, Mariah Lenox <mariah...@gmail.com> wrote:
>
> The open trac tickets #4644 and #5507 discuss
> problems with "sage -sh", specifically
>
> #4644 - No new prompt when doing a ./sage -sh
I can confirm that your patch fixes this issue:
{{{
[mvngu@sage sage-4.1.1]$ ./sage -sh
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 ...
sage$ exit
exit
Exited Sage subshell.
}}}
> #5507 - $ sage -sh -c "echo hi there" # does not work, but should
It also fixes this one as well:
{{{
[mvngu@sage sage-4.1.1]$ ./sage -sh -c "echo hi there"
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 ...
hi there
Exited Sage subshell.
}}}
> $ sage -sh -c -c "echo hi there" # works, but shouldn't
This one still works:
{{{
[mvngu@sage sage-4.1.1]$ ./sage -sh -c -c "echo hi there"
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 ...
hi there
Exited Sage subshell.
}}}
> There is also a problem that "sage -sh" may pick up the user's
> $PATH rather than the one defined in sage-env (which
> is how I got into this issue).
With the patch, the user's $PATH is picked up, but variables in
sage-env are prepended to it:
{{{
[mvngu@sage sage-4.1.1]$ echo $PATH
/home/mvngu/usr:/home/mvngu/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
[mvngu@sage sage-4.1.1]$
[mvngu@sage sage-4.1.1]$ ./sage -sh
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 ...
sage$ echo $PATH
/scratch/mvngu/build/sage-4.1.1:/scratch/mvngu/build/sage-4.1.1/local/bin:/home/mvngu/usr:/home/mvngu/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
sage$ exit
exit
Exited Sage subshell.
}}}
> The patch below fixes these three problems - but it may
> not be what developers want. Specifically, it will set the
> prompt to be "sage $" for all shells (with the exception of
> csh which does not have a prompt environment variable and
> so the prompt gets set to "%"). Note that with the patch
> the prompt is NOT listing the current directory.
>
> Do developers prefer that a sage-sub-shell prompt list
> the current directory?
Yes, that would be nice.
--
Regards
Minh Van Nguyen
Possibly a bit out of context. But I was hit by "sage -sh"
yesterday. I run "./sage -sh" to make some tests, and gone do other
duties in the meantime. Then, I forgot I was under a sage 4.1.1 shell
in that xterm, and things started working incorrectly.
Curiously, I had been debugging a problem with
java-1.6-openjdk-plugin and java-1.6-sun-plugin, where only the sun
plugin works in my Mandriva setup, when loading the jmol plugin. (I
was testing/comparing both, the mandriva rpm package, and sage-4.1.1
binary downloaded from a sagemath mirror).
Then, after playing with install/uninstall of several packages, I
ended up in a state where firefox would always refuse to start, and
the reason was LD_LIBRARY_PATH, because I was starting firefox from
the xterm that was running "sage -sh".
Paulo
I converted your patch to our Mercurial format and posted it at ticket
#4644, and left a comment on ticket #5507.
Dan
--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------