'/tmp/file' -> '../a/file'
@end smallexample
+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.
@xref{realpath invocation}, which gives greater control
-over relative file name generation.
+over relative file name generation, as demonstrated in the following example:
+
+@example
+@verbatim
+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"
+}
+@end verbatim
+@end example
@item -s
@itemx --symbolic
ln -srf here existing_link
test $(readlink existing_link) = 'here' || fail=1
+# Demonstrate resolved symlinks used to generate relative links
+# so here, 'web/latest' will not be linked to the intermediate 'latest' link.
+# You'd probably want to use realpath(1) in conjunction
+# with ln(1) without --relative to give greater control.
+ln -s release1 alpha
+ln -s release2 beta
+ln -s beta latest
+mkdir web
+ln -sr latest web/latest
+test $(readlink web/latest) = '../release2' || fail=1
+
Exit $fail