The realpath executable works well, but it creates a chicken and egg problem: In order to use it, scripts need to locate it. But I think we can rewrite scripts to work without it. Consider this shell script:
#!/bin/sh
LINK="$@"
while [ "$LINK" ]; do
cd "$(dirname $LINK)"
LINK="$(readlink $(basename $LINK))"
done
echo "$PWD"
This takes a file path as argument, and returns the "real" path of its parent dir (not quite "real", because it doesn't expand symlinks up to the top, but that shouldn't matter for our purposes).
The
realpath
executable works well, but it creates a chicken and egg problem: In order to use it, scripts need to locate it. But I think we can rewrite scripts to work without it. Consider this shell script:This takes a file path as argument, and returns the "real" path of its parent dir (not quite "real", because it doesn't expand symlinks up to the top, but that shouldn't matter for our purposes).
For example, in
gap.sh
, right now we havewhich could be replaced by