realpath
realpath copied to clipboard
Fails to find realpath of directory symlink
realpath ./foo/this-is-a-symlink fails to resolve the symlink.
pwd # assume we're in /home/cspotcode
mkdir -p foo
ln -s .. ./foo/this-is-a-symlink
# ./foo/this-is-a-symlink points to .. (points to /home/cspotcode)
realpath ./foo/this-is-a-symlink # Native realpath outputs "/home/cspotcode"
realpath-bash-implementation ./foo/this-is-a-symlink # Erroneously outputs "/home/cspotcode/foo/bar"
pwd -P will resolve symlinks for everything except the last item of the path. So it doesn't resolve this-is-a-symlink.