On Apr 30, 2:06 am, M <[EMAIL PROTECTED]> wrote: > Dear All, Hi Max,
> I just tried making a symlink to sage and it broke because it defaults > to using $0 to work out where SAGE_DIR is. I'd like to propose a > small change that allows symlinks to be used: > > --------------------------- > THE FILE: is the shell script called sage in the root of the install > tree and which starts: > > #!/bin/sh > > # Set SAGE_ROOT to the location of the sage install. > SAGE_ROOT="....." > > CUR="`pwd`" # save the current directory, so can change back after > startup > > if [ "$SAGE_ROOT" = "....." ]; then > SAGE_ROOT=`echo "$0" | sed -e 's/....$//g'` > ----------------------------- > BEFORE: The line I'd like to change is: > > SAGE_ROOT=`echo "$0" | sed -e 's/....$//g'` > > ---------------------------- > AFTER: > > SAGE_ROOT=`readlink -f "$0"` 2>/dev/null || \ > SAGE_ROOT=`realpath "$0"` 2>/dev/null || \ > SAGE_ROOT="$0" > > SAGE_ROOT="${SAGE_ROOT%/*}/" > > -------------------------- > DISCUSSION: > readlink -f and realpath do the same thing - they get a clean path > free of relative components and symlinks. > > The reason for trying both is that some systems have only the one or > the other. Trying raw $0 is there as a last resort just in case. > Don't want to break any existing installs! > > The final line does -almost- the same as the sed. The sed removes > four characters (sage), the new code removes the file part of the > path. Debatable but it's a bit quicker than spawning a sed process > and allows for name changes. You never know.. it might become > fennel. All right, this part of the argument is pretty weak! You end up fork the shell anyway to launch sed, realpath or readlink, but all of it is cheap and looking at all the other stuff we do at startup it shouldn't even be noticeable in the noise anyway. > But the upside is that I can now make symlinks to sage and everything > works dandy, which it didn't before. Yes, I like the solution. If you could provide a patch it would make fixing this even faster ;). We are now tracking this at http://trac.sagemath.org/sage_trac/ticket/3061 > Have fun! > > And sorry about not using [code] tags .. I couldn't find the button! > (wimp) Don't worry about that. Google groups is essentially email, so no code tags around here. > Regards, Max (new to this forum) Cheers, Michael --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---