The feature introduced in #25486 (Discover SAGE_SCRIPTS_DIR to make $SAGE_LOCAL/bin/sage work from any directory, in an environment without SAGE_* variables) was killed by #30128 (enforce sourcing of sage-env-config before src/bin/sage-env).
We repair it, making sure that it works even if $0 is a symlink.
CC:  @orlitzky @dimpase @jhpalmieri
Component: scripts
Keywords: sd111
Author: Michael Orlitzky
Branch/Commit: a63d256
Reviewer: Matthias Koeppe
Issue created by migration from https://trac.sagemath.org/ticket/30888