From coreutils' manual about ln
-r
--relative
Make symbolic links relative to the link location.
Example:
ln -srv /a/file /tmp ’/tmp/file’ -> ’../a/file’
Relative symbolic links are generated based on their canonicalized containing directory, and canonicalized targets. I.e., all symbolic links in these file names will be resolved. See Section 18.5 [realpath invocation], page 161, which gives greater control over relative fi le name generation, as demonstrated in the following example:
ln--relative() { test "$1" = --no-symlinks && { nosym=$1; shift; } target="$1"; test -d "$2" && link="$2/." || link="$2" rtarget="$(realpath $nosym -m "$target" \ --relative-to "$(dirname "$link")")" ln -s -v "$rtarget" "$link" }
Is the purpose of the example ln--relative()
to implement the same asln -sr
? Thanks.