Is there a concise way of reading a symlink and making sure that the result represents an absolute file location?
As a specific example, Debian is switching […] to/etc/resolv.conf -> ../run/resolvconf/resolv.conf
The full path
/etc/../run/resolvconf/resolv.conf is already absolute. It starts with a forward slash. Simple concatenation of the symlink’s location and its target (unless the target is specifying an absolute path, obviously).
If I understand you correctly, your task is to
collapse unnecessary
directory traversal. So
/../../../../../../.. is collapsed to to
/. The problem is,
path_resolution(7) depends on many factors. It’s not done with a plain string pattern replacement.
PS: What would be
your expected result if, say, the directory
resolvconf was itself a symbolic link again?