1 | | Currently, {{{$SAGE_ROOT/sage}}} uses (first among other alternate methods) {{{readlink -n}}} to detect the directory where the script lives (that's $SAGE_ROOT), but it should use {{{readlink -nf}}} to expand symlinks recursively. |

2 | | |

3 | | Otherwise, the symlink expansion may not be completely done, and {{{$SAGE_ROOT}}} could end up with a non-canonical dirname, which leads to issues with testing. |

| 1 | Currently, {{{$SAGE_ROOT/sage}}} uses (first among other alternate methods) {{{readlink -n}}} to detect the directory where the script lives (that's $SAGE_ROOT), but that is broken because |

| 2 | - It only works when `$0` (the sage executable itself) is a symbolic link |

| 3 | - If the sage executable is a symbolic link, then `readlink -n` returns the link itself, not the canonicalized name. Example: if `/usr/local/sage-4.7.1/sage` is a symbolic link to `sagefoo`, then `SAGE_ROOT` would become `sagefoo` when `'/usr/local/sage-4.7.1/sagefoo` is intended. |

| 4 | - The symlink expansion may not be completely done, and {{{$SAGE_ROOT}}} could end up with a non-canonical dirname, which leads to issues with testing. |