#6146: the detection of SAGE_ROOT in $SAGE_ROOT/sage script should expand
symlinks
recursively (fix this on systems that do *NOT* support readlink -f)
-----------------------+----------------------------------------------------
Reporter: was | Owner: cwitty
Type: defect | Status: closed
Priority: major | Milestone: sage-duplicate/invalid/wontfix
Component: misc | Resolution: duplicate
Keywords: | Work_issues:
Upstream: N/A | Reviewer: Jeroen Demeyer
Author: | Merged:
Dependencies: |
-----------------------+----------------------------------------------------
Comment(by tornaria):
Replying to [comment:5 jdemeyer]:
- resolution set to duplicate
Duplicate of which ticket?
For convenience, here's a copy of the path-detection code in the tarball
above. The tarball also contains a number of tests for different cases of
symlinks in-the-path or in-the-script.
{{{
#!/usr/bin/env bash
realpath_bash()
{
fname="${1%/}" # strips trailing '/'
while [ -L "$fname" ] ; do
dir="$(dirname "$fname")"
fname="$(command ls -l "$fname")"
fname="${fname#*\> }"
if [ "$fname" = "." ] ; then
fname="$dir"
elif echo "$fname" | grep -v '^/' > /dev/null ; then
fname="$dir/$fname"
fi
done
pushd "$(dirname "$fname")" > /dev/null
echo "$(pwd -P)/$(basename "$fname")"
popd > /dev/null
}
SAGE_PATH="$(realpath "$0" 2> /dev/null)" || \
SAGE_PATH="$(readlink -f "$0" 2> /dev/null)" || \
SAGE_PATH="$(realpath_bash "$0" 2> /dev/null)" || \
SAGE_PATH="$0"
SAGE_ROOT="$(dirname "$SAGE_PATH")"
echo "SAGE_ROOT:$SAGE_ROOT:"
}}}
Please see also the discussion in #5852, which is concerned with
canonicalizing $SAGE_ROOT when readlink -f is available --- a fix that
works for that case was merged in 4.0.rc1 and reverted in 4.1.rc0 because
it caused a regression for somebody.
This ticket is concerned with how to portably canonicalize $SAGE_ROOT in
general (when readlink -f is not available) and it was stalled because
canonicalization (as done in #5852) caused other issues that weren't
resolved. Once using a fully canonical $SAGE_ROOT is workable (using
readlink -f) then we can expand the portability of the canonicalization
using the solution proposed here (or any other solution).
[see also #11707]
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6146#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.