8d4bc79d10f6f236c94e3822274cabc2c33c587b
[platform/upstream/coreutils.git] / tests / ls / inode.sh
1 #!/bin/sh
2 # Make sure that ls -i works properly on symlinks.
3
4 # Copyright (C) 2003-2013 Free Software Foundation, Inc.
5
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.
10
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.
15
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/>.
18
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ ls
21
22 touch f || framework_failure_
23 ln -s f slink || framework_failure_
24
25
26 # When listed explicitly:
27
28 set x $(ls -Ci f slink); shift
29 test $# = 4 || fail=1
30 # The inode numbers should differ.
31 test "$1" != "$3" || fail=1
32
33 set x $(ls -CLi f slink); shift
34 test $# = 4 || fail=1
35 # With -L, they must be the same.
36 test "$1" = "$3" || fail=1
37
38 set x $(ls -CHi f slink); shift
39 test $# = 4 || fail=1
40 # With -H, they must be the same, too, from the command line.
41 # Note that POSIX says -H must make ls dereference only
42 # symlinks (specified on the command line) to directories,
43 # but the historical BSD meaning of -H is to dereference
44 # any symlink given on the command line.  For compatibility GNU ls
45 # implements the BSD semantics.
46 test "$1" = "$3" || fail=1
47
48 # When listed from a directory:
49
50 set x $(ls -Ci); shift
51 test $# = 4 || fail=1
52 # The inode numbers should differ.
53 test "$1" != "$3" || fail=1
54
55 set x $(ls -CLi); shift
56 test $# = 4 || fail=1
57 # With -L, they must be the same.
58 test "$1" = "$3" || fail=1
59
60 set x $(ls -CHi); shift
61 test $# = 4 || fail=1
62 # With -H, they must be different from inside a directory.
63 test "$1" != "$3" || fail=1
64
65 Exit $fail