From 15b8318e93a947d1422e9a927f699eda1085cf0d Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 22 Mar 2012 20:51:20 +0000 Subject: ln: add the --relative option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the "--relative --symbolic" options, ln computes the relative symbolic link for the user. So, ln works just as cp, but creates relative symbolic links instead of copying the file. I miss this feature since the beginning of using ln. $ tree ./ / `-- usr |-- bin `-- lib `-- foo `-- foo 4 directories, 1 file $ ln -s -v --relative usr/lib/foo/foo usr/bin/foo ‘usr/bin/foo’ -> ‘../lib/foo/foo’ $ tree ./ / `-- usr |-- bin | `-- foo -> ../lib/foo/foo `-- lib `-- foo `-- foo 4 directories, 2 files $ ln -s -v --relative usr/bin/foo usr/lib/foo/link-to-foo ‘usr/lib/foo/link-to-foo’ -> ‘foo’ $ tree ./ / `-- usr |-- bin | `-- foo -> ../lib/foo/foo `-- lib `-- foo |-- link-to-foo -> foo `-- foo 4 directories, 3 files * src/Makefile.am: Reference the relpath module. * src/ln.c (usage): Mention the new option. (do_link): Call the relative conversion if specified. (convert_abs_rel): Perform the relative conversion using the relpath module. * tests/ln/relative: Add a new test. * tests/Makefile.am: Reference the new test. * doc/coreutils.texi: Document the new feature. * NEWS: Mention the new feature. --- doc/coreutils.texi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'doc') diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 10be7156b..b7208aa5f 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -9389,6 +9389,22 @@ symbolic link with identical contents; since symbolic link contents cannot be edited, any file name resolution performed through either link will be the same as if a hard link had been created. +@item -r +@itemx --relative +@opindex -r +@opindex --relative +Make symbolic links relative to the link location. + +Example: + +@smallexample +ln -srv /a/file /tmp +'/tmp/file' -> '../a/file' +@end smallexample + +@xref{realpath invocation}, which gives greater control +over relative path generation. + @item -s @itemx --symbolic @opindex -s -- cgit v1.2.3-70-g09d2