mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-09 21:53:55 +02:00
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.
33 lines
1.1 KiB
Bash
Executable File
33 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# Test "ln --relative".
|
|
|
|
# Copyright (C) 2012 Free Software Foundation, Inc.
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
|
print_ver_ ln
|
|
|
|
mkdir -p usr/bin || framework_failure_
|
|
mkdir -p usr/lib/foo || framework_failure_
|
|
touch usr/lib/foo/foo || framework_failure_
|
|
|
|
ln -sr usr/lib/foo/foo usr/bin/foo
|
|
test $(readlink usr/bin/foo) = '../lib/foo/foo' || fail=1
|
|
|
|
ln -sr usr/bin/foo usr/lib/foo/link-to-foo
|
|
test $(readlink usr/lib/foo/link-to-foo) = 'foo' || fail=1
|
|
|
|
Exit $fail
|