maint: use single copyright year range
[coreutils/ericb.git] / tests / ln / hard-to-sym
blob044b10c0dfca82a808c686e0cf6fbcf946d40c50
1 #!/bin/sh
2 # Tests for ln -L/-P.
4 # Copyright (C) 2009-2012 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/init.sh"; path_prepend_ ../src
20 print_ver_ ln
23 # ===================================================
24 # ensure -s silently overrides -L, -P
25 touch a || framework_failure_
26 ln -L -s a symlink1 || fail=1
27 ln -P -s symlink1 symlink2 || fail=1
28 ln -s -L -P symlink2 symlink3 || fail=1
30 # ===================================================
31 # ensure that -L follows symlinks, and overrides -P
32 ln -P -L symlink3 hard-to-a || fail=1
33 ls=`ls -lG hard-to-a`x
34 case "$ls" in
35 *'hard-to-ax') ;;
36 *'hard-to-a -> '*x) fail=1 ;;
37 *) framework_failure_ ;;
38 esac
40 # ===================================================
41 # ensure that -P links (or at least duplicates) symlinks, and overrides -L
42 ln -L -P symlink3 hard-to-3 || fail=1
43 ls=`ls -lG hard-to-3`x
44 case "$ls" in
45 *'hard-to-3 -> symlink2x') ;;
46 *'hard-to-3x') fail=1 ;;
47 *'hard-to-3 -> '*x) fail=1 ;;
48 *) framework_failure_ ;;
49 esac
51 # ===================================================
52 # Create a hard link to a dangling symlink.
53 ln -s /no-such-dir || framework_failure_
54 ln -L no-such-dir hard-to-dangle 2>err && fail=1
55 case `cat err` in
56 *" accessing 'no-such-dir'":*) ;;
57 *) fail=1 ;;
58 esac
59 ln -P no-such-dir hard-to-dangle || fail=1
61 # ===================================================
62 # Create a hard link to a symlink to a directory.
63 mkdir d || framework_failure_
64 ln -s d link-to-dir || framework_failure_
65 ln -L link-to-dir hard-to-dir-link 2>err && fail=1
66 case `cat err` in
67 *": 'link-to-dir': hard link not allowed for directory"*) ;;
68 *) fail=1 ;;
69 esac
70 ln -P link-to-dir/ hard-to-dir-link 2>err && fail=1
71 case `cat err` in
72 *": 'link-to-dir/': hard link not allowed for directory"*) ;;
73 *) fail=1 ;;
74 esac
75 ln -P link-to-dir hard-to-dir-link || fail=1
77 Exit $fail